Not sure if this is a bug or there is a reason behind this, but when i use CDbCriteria like this:
$criteria = new CDbCriteria;
$criteria->compare('userId', 4);
$criteria->addCondition('subject LIKE :subject');
$criteria->params = array(':subject' => 'subjecttest');
$messageThread = MessageThread::model()->findAll($criteria);
The ‘userId’ is not bound while ‘:subject’ is correctly bound (“Bound with :subject=‘subjecttest’”), which gives me the following error:
"Invalid parameter number: number of bound variables does not match number of tokens"
When i use it like this:
$criteria = new CDbCriteria;
$criteria->compare('userId', 4);
$messageThread = MessageThread::model()->findAll($criteria);
The ‘userId’ is correctly bound (“Bound with :ycp0=‘4’”) and the query is executed succefully.
When i use it like this:
$criteria = new CDbCriteria;
$criteria->addCondition('subject LIKE :subject');
$criteria->params = array(':subject' => 'subjecttest');
$messageThread = MessageThread::model()->findAll($criteria);
The ‘:subject’ is correctly bound (“Bound with :subject=‘subjecttest’”) and the query is executed succefully.
I expected the two individual ‘params’ would be merged (as in my first code example), but this is not the case.