I'd use "IN":
$update = array('deleted' => 1);
$where = array('id IN (?)' => $ids); // $ids is array of ids to update
$table->update($update, $where);
All done in 1 query with no SELECTS (or find()s).
--
Hector
On Wed, Dec 23, 2009 at 10:59 AM, Biffster <[email protected]>wrote:
>
> I have a form which lets a user select from a list of messages they've
> received. The form has checkboxes as multicheckboxes (using the
> multicheckbox helper) so that the selected values are passed to PHP as an
> array.
>
> I then want to delete all selected messages (virtual deletion, i.e setting
> a
> field called "deleted" to true) and can think of two possible options:
> 1) One query, with loads of "OR WHERE messageid=id" clauses which returns
> a
> rowset. I can loop through the rowset, set the deleted field to true, and
> then save();
> 2) Several queries to receive a single row each time, set the deleted
> value
> to true and save();
>
> By default there's a maximum of 10 messages that can be deleted at one time
> (pagination limit that I set), but I guess this could increase if I gave
> users the option to choose how many to display per page.
>
> Which of the two options would give better performance? Is there an even
> better alternative way?
>
> Thanks in advance for all your help!
>
>
> --
> View this message in context:
> http://n4.nabble.com/OR-WHERE-clause-performance-tp978002p978002.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>