When creating an update command involving joins, the command builder won’t take MySQLs special needs into account: MySQL expects the query to be something like
UPDATE table JOIN table2 ON id=id2 SET column='value'
while the command builder will create something like
UPDATE table SET column='value' JOIN table2 ON id=id2
This can be reproduced pretty quickly within the Yii blog demo:
Post::model()->updateAll(array(
'content'=>'m00',
), array(
'join'=>'JOIN {{user}} u ON `author_id`=u.`id`',
'condition'=>'u.`username`="demo"',
));
I realize that this type of query is rather rare. But it’s not entirely impossible. What is leaving me puzzled: There is a patch for this ready since september, seeing very little love. So what is keeping this bug from being fixed?