cphalcon
cphalcon copied to clipboard
Error in SQL while searching with criteria (0.8.0)
Updated to 0.8.0. Using standart code from scaffold. Now gets error
if ($this->request->isPost()) {
$query = \Phalcon\Mvc\Model\Criteria::fromInput($this->di, "Product", $_POST);
$this->session->conditions = $query->getConditions();
} else { ...
You have an error in your SQL syntax; ... near ':points ORDER BY `product`.`id`' at line 1
SELECT `product`.`id`, `product`.`stock`...
... WHERE `product`.`points` = :points ORDER BY `product`.`id`
Is it a bug, or some change to code is reuqired? Same problem with different tables/models.
It must be:
if ($this->request->isPost()) {
$criteria = \Phalcon\Mvc\Model\Criteria::fromInput($this->di, "Product", $_POST);
$this->session->parameters = $criteria->getParams();
} else {
//...
}
Product::find($this->session->parameters);
The $criteria->getConditions() only returns the WHERE clause of the query and getParams returns the conditions + the bound parameters.
Using the standard code from scaffold produces the error above.