I’m trying to run a native SQL query using doctrine and am running into problems with it quoting the numbers for the LIMIT part of my query.
$offset = $pageNumber * self::$limit;
$sql = "
SELECT * FROM devices LIMIT :offset, :limit
";
$stmt = self::getEntityManager()->getConnection()->prepare($sql);
$stmt->bindValue("offset", $offset);
$stmt->bindValue("limit", self::$limit);
$stmt->execute();
$result = $stmt->fetchAll();
Generates:
SELECT * FROM devices LIMIT '0', '5000'
Which is not valid. I’m a little stumped on how I can alter this to produce:
SELECT * FROM devices LIMIT 0, 5000
I’ve referenced data-retrieval-and-manipulation which has a section about the quote() functions, but it’s shy on details.
Try :
See source here: