zarun
(Z Arunbasnet)
January 13, 2012, 6:10pm
1
Hi,
I’ve been trying to figure out what went wrong in this:
$bc_model->updateAll(array('business_id' => $business_id),'contact_id IN (:contactids)',array(':contactids' => implode(',',$contactids)));
The query generated is:
system.db.CDbCommand.execute(UPDATE `business_contact` SET `business_id`=:yp0 WHERE contact_id IN (:contactids))
What is it that I am missing?
Say_Ten
(Yii)
January 16, 2012, 5:26pm
3
I suspect that you end up with contact ids being one big string with commas in. Perhaps build a CDbCriteria using the addInCondition and parsing that in for the criteria would be best for you.
zarun
(Z Arunbasnet)
January 24, 2012, 4:01pm
4
Thanks a lot,
I tried this and it worked:
$criteria->addInCondition( "contact_id" , $contactids );
$model->updateAll(array('business_id' => $business_id), $criteria);