We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Model update problem

Hi, I have got problem with update model

$robot = Robots::findFirst("id=7");
$robot->color = "blue";
$robot->update();

I got PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens What could make this error ?

#0  PDOStatement->execute()
#1  Phalcon\Db\Adapter\Pdo->executePrepared(Object(PDOStatement), Array(20), Array(20))
#2  Phalcon\Db\Adapter\Pdo->execute(UPDATE `****` SET `****` = ?, `****` = ?, `****` = ?, `****` = ?, `****` = ?, `****` = ?, `****` = ?, `***` = ?, `****` = ?, `****` = ?, `****` = ?, `****` = ?, `****` = ?, `****` = ?, `****` = ?, `****` = ?, `****` = ?, `****` = ?, `***` = ? WHERE 0, Array(20), Array(20))
#3  Phalcon\Db\Adapter->update(****, Array(19), Array(19), Array([conditions] => 1, [bind] => Array([0] => 17), [bindTypes] => 0), Array(19))
#4  Phalcon\Mvc\Model->_doLowUpdate(Object(Phalcon\Mvc\Model\MetaData\Memory), Object(Phalcon\Db\Adapter\Pdo\Mysql), rozliczenia)
#5  Phalcon\Mvc\Model->save()
#6  Phalcon\Mvc\Model->update()


98.9k

Does the mapped table have a primary key?

Yes, table have got primary key id, and when i print_r($robot->toArray()); I can fetch record, but can't update it, can't save it.



98.9k

Can you please create a gist like this one: https://gist.github.com/phalcon/5610396, with the coding that are falling?

I will create it later. Maybe I find solution.