Hi
updateAll ignores criteria defined on the model using scopes, so I did something like the following:
$criteria=new CDbCriteria();
MyAR::model()->scope1()->scope2()->applyScope($criteria);
MyAR::model()->updateAll(array('fieldtoupdate'=>'newvalue'),$criteria);
However that fails as the criteria use the ‘t’ alias and that alias is not applied when the UPDATE command is constructed. I am using 1.1.12, but this is also true in 1.1.13.
The workaround is to add one line before:
MyAR::model()->getDbCriteria()->alias=MyAR::model()->tableName();
$criteria=new CDbCriteria();
MyAR::model()->scope1()->scope2()->applyScope($criteria);
MyAR::model()->updateAll(array('fieldtoupdate'=>'newvalue'),$criteria);
Edit: I have now written a Wiki for this: http://www.yiiframework.com/wiki/728/using-updateall-and-deleteall-with-scopes/