On 12/15/06, Christopher H. Laco <[EMAIL PROTECTED]> wrote: > When deleting an object, one can pass the cascade option so it will > delete all child objects in a relationship. In my case, passing cascade > to the cart object, will delete the cart and all of it's related items: > > $cart->delete(cascade => 1); > > Is there a way to do this same thing when delete multiple objects using > Object Manager? > > R::D::O::Manager->delete_objects( > object_class => 'Carts', > where => [status => 0], > )
Yeah, it's called ON DELETE CASCADE in your database :) All the Manager is doing is issuing a DELETE FROM cards WHERE ... query. (In general, all any Manager method ever does is issue a single query.) Deleting all related objects would require either retrieving and tracking all related object ids, or manually tracing through the relationships until some "end" is reached, and then deleting in the reverse direction using a series of (potentially really big) subselects. Neither approach is efficient, and both may not actually terminate in the case of circular relationships. If you need to do this kind of thing, I suggest either using ON DELETE CASCADE in the database (by far the best method) or adding explicit code to support cascade in a custom Manager method. -John ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object