updateByPk how to use with condition ?

I’m using updateByPk but . I only use with update with PK

a row in my table must change when sql execute.


then, can you explain for me about :

$condition and $params ??

how to use

please help me

Konichiwa, Konichiwa :)

The usage of $condition and $params are identical as in find() method:



So, the usage is such like this:

Post::model()->updateByPk($pks, 'author_id = :author_id', array('author_id'=>$myId));


Post::model()->updateByPk($pks, new CDbCriteria(array('condition'=>'author_id = :author_id', 'params'=>array('author_id'=>$myId))));

or you can just create a separate variable that would contain your CDbCriteria object:

$c = new CDbCriteria()



That is!

Thank you very much