Thanks Jacob. In my case I will have already hydrated the objects and need to use them before the delete anyway.
My question relates to how best to do the delete after that. i.e. rather than have 1000 lines like this: DELETE FROM mytable WHERE id=1 DELETE FROM mytable WHERE id=2 etc... DELETE FROM mytable WHERE id=1000 I'd rather generate something like DELETE FROM mytable WHERE id IN(1,2,....1000) At least I assume that will be more efficient. Right? Per your suggestion I suppose can do this, but see below: <code> $c = new Criteria(); $c->add(your criteria); $results = doSelect($c); // now I process the results for a while EventPeer::doDelete($c); </code> But I assume that the criteria $c could imply different rows in the table if records were inserted by someone else between the doSelect and the doDelete. So I guess I could also do this: <code> $c = new Criteria(); $c->add(your criteria); $results = doSelect($c); // now I process the results for a while // then I build a big string '(id1, id2, ..., id1000)' -- with $result['ID'] inserted // then: $c = new Criteria(); $c->add(myClassPeer::ID, $list, Criteria::IN); EventPeer::doDelete($c); </code> Is that the best way? Or, does the result set actually have a mass- delete method? $result->delete(). Sorry for being lazy and not slogging thru the code to figure that out but thought I'd ask to see if someone knows the answer. On Oct 22, 1:17 pm, Jacob Coby <[email protected]> wrote: > $c = new Criteria(); > $c->add(your delete criteria); > > EventPeer::doDelete($c); > > That will delete the rows according to your criteria without hydrating > objects into memory. > > On Oct 22, 2009, at 12:24 PM, fbg wrote: > > > > > > > Suppose that I have a symfony 1.0 app and perform a propel query, work > > with the results a bit, and then wish to delete the underlying > > database records (for example, to scrub a log table, send out any > > needed alert emails, and roll the log events into a flat file to keep > > the DB fresh). > > > What is the most efficient way to tell sf to do the delete? > > > eg: > > > ...criteria...LIMIT 1000 OFFSET N ... > > $results = doSelect (or doSelectRs) ... > > foreach($results as $result) > > { > > // process the result then: > > $result->delete(); > > } > > > OR, is there a $results->delete(); if so, are they equivalent? > > > What I'm wondering about is whether sf will generate 1000 DELETE SQL > > requests, or whether there will be something else like DELETE ... > > WHERE id IN (i1,i2,...,i1000). I assume the latter would be much more > > efficient. Comments? > > > Thanks in advance for any advice. > > -- > Jacob Coby --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~----------~----~----~----~------~----~------~--~---
