Infamous updateAll problem

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? :(

what is the error ?

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.

Thanks a lot,

I tried this and it worked:




$criteria->addInCondition( "contact_id" , $contactids ); 

$model->updateAll(array('business_id' => $business_id), $criteria);