Hi.
I have ealier written about bind params with modelsManager, now i am using the Query and get the same error.
This is my model
<?php
use Phalcon\Mvc\Model,
Phalcon\Mvc\Model\Query;
class Pictures extends Model
{
public function getPictures($limit, $offset)
{
$phql = "SELECT p.id, p.filename, p.likes FROM pictures p WHERE p.status = 'Active' ORDER BY p.id DESC LIMIT :limit: OFFSET :offset:";
$pictures = new Query($phql, $this->getDI());
return $pictures->execute(array(
'limit' => $limit,
'offset' => $offset
),
array(
'limit' => \Phalcon\Db\Column::BIND_PARAM_INT,
'offset' => \Phalcon\Db\Column::BIND_PARAM_INT
));
}
}
And another thing, OFFSET seems to be wrong. In SQL is the statement look like "LIMIT x,y" but that doesn't work.
What am i doing wrong? My error is
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''20' OFFSET '2'' at line 1' in /media/sf_pattegufv3/app/models/Pictures.php:44 Stack trace: #0 [internal function]: PDOStatement->execute() #1 [internal function]: Phalcon\Db\Adapter\Pdo->executePrepared(Object(PDOStatement), Array, Array) #2 [internal function]: Phalcon\Db\Adapter\Pdo->query('SELECT `p`.`id`...', Array, Array) #3 [internal function]: Phalcon\Mvc\Model\Query->_executeSelect(Array, Array, Array) #4 /media/sf_pattegufv3/app/models/Pictures.php(44): Phalcon\Mvc\Model\Query->execute(Array, Array) #5 /media/sf_pattegufv3/app/controllers/PictureController.php(23): Pictures->getPictures('20', '2') #6 [internal function]: PictureController->picturesAction() #7 [internal function]: Phalcon\Dispatcher->dispatch() #8 /media/sf_pattegufv3/public/index.php(44): Phalcon\M in /media/sf_pattegufv3/app/models/Pictures.php on line 44
i call /pictures?limit=20&offset=2