$criteria = new CDbCriteria;
$criteria->condition='id=:jednotka_id OR jednotka_id=:jednotka_id';
$criteria->params=array(':jednotka_id'=>$jednotka_id);
Jednotka::model()->findAll($criteria);
Application log:
CDbCommand::fetchAll() failed: SQLSTATE[HY093]: Invalid parameter number. The SQL statement executed was: SELECT * FROM jednotkat WHERE id=:jednotka_id OR jednotka_id=:jednotka_id. Bound with :jednotka_id=6101601.
Workaround:
Jednotka::model()->findAll(‘id=’.$jednotka_id.’ OR jednotka_id=’.$jednotka_id);
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);
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.