Hi I want to do this.
UPDATE images SET is_primary = 0 WHERE event_id = $id
from events controller, where Event hasMany Image.
Hi I want to do this.
UPDATE images SET is_primary = 0 WHERE event_id = $id
from events controller, where Event hasMany Image.
$this->Event->saveAll($this->data);
See: http://book.cakephp.org/view/84/Saving-Related-Model-Data-hasOne-hasMany-belongsTo
and: http://api12.cakephp.org/class/model#method-ModelsaveAll
Alternatively, you can save the Event, then loop over and save each Image.
There is also the option of:
$this->Image->query("UPDATE images SET is_primary = 0 WHERE event_id = $id");
$this->Event->Image->updateAll(array('is_primary'=>0), array('Event.id'=>$id));
Check this and search for updateAll