Findall - Invalid Parameter Number. But Worked Before.


$criteria = new CDbCriteria;

$criteria->condition='id=:jednotka_id OR jednotka_id=:jednotka_id';



Application log:

CDbCommand::fetchAll() failed: SQLSTATE[HY093]: Invalid parameter number. The SQL statement executed was: SELECT * FROM jednotka t WHERE id=:jednotka_id OR jednotka_id=:jednotka_id. Bound with :jednotka_id=6101601.


Jednotka::model()->findAll(‘id=’.$jednotka_id.’ OR jednotka_id=’.$jednotka_id);

Any idea why first code stop working?



i had similar issue, somehow you could not re-use parameter in this case, try

$criteria->condition='id=:jednotka_id1 OR jednotka_id=:jednotka_id2';

$criteria->params=array(':jednotka_id1'=>$jednotka_id1, ':jednotka_id2'=>$jednotka_id2);

Thanks for the answer. Your code works.

However it does not explain why the code stopped working. Worked over half a year. I made some changes on project today, but only minor changes - not core files.

It looks like stop working when I turn off emulatePrepare in my config.