Re: DB_DataObject multiple deletes

From: Date: Wed, 27 Jul 2005 23:57:04 +0000
Subject: Re: DB_DataObject multiple deletes
References: 1 2 3 4 5 6  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-20170@lists.php.net to get a copy of this message
Hi Justin, As there could be a lot of records I could end up with a monster where clause, so I've opted for the "create a new DB_DO object" approach and it seems to work well. Thank you for your help. Regards, Etienne. "Justin Patrin" <papercrane@gmail.com> wrote in message news:432beae05072716433d71235d@mail.gmail.com... On 7/27/05, Etienne van Tonder <evt@infoware.com.au> wrote: Thanks for delving into all of this. Ok, I'm just realizing that this is isn't a normal use (duh). Since you're calling get() on it it's basically assumed that this DO will not be re-used. If you did something like this instead: $do->whereAdd('conditions to get the records you want to delete'); if ($do->find()) { while ($do->fetch()) { $do->delete(); } } Then that *should* work. I'm pretty sure I'm using that in my own scripts. However if you still want to use get() I suggest you create a new DO every time within the loop. DB_DO objects are set up to work with *one* fetching query. If you use find()/fetch() as above it's ok, but if you do multiple get()s it gets strange. There really is no reason for you to use the same one here. If you think you have a fix for this please submit it in the bug tracker.

« previous php.pear.general (#20170) next »