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.


Post::model()->updateByPk($pk,$attributes,$condition,$params);

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:

$criteria

$params

So, the usage is such like this:


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

or


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()

$c->condition=...

...

That is!

Thank you very much