Re: Dependencies and shared lists

67 views
Skip to first unread message

gabor

unread,
Nov 10, 2012, 7:10:13 AM11/10/12
to redbe...@googlegroups.com

Hi,

You don't need to define a dependency for this, RedBeanPHP cleans link tables automatically because the records themselves are
meaningless. Dependencies are only meant for N-1 relations.

Cheers,
Gabor

On Saturday, November 10, 2012 12:04:31 AM UTC+1, cslinuxboy wrote:
I am using shared lists (many-many relationship) and would like to create dependencies to take advantage of cascading deletes.  But I don't know if I'm doing things correct.  I have three tables; Watches, Events, and Events_Watches.  There is a many-many relationship between the Watches and Events (Watches can have many Events).  Therefore, RB created the Events_Watches table for me via the sharedEvents variable for a Watches bean.  So how would I construct the dependency?  

Would it be 
R::dependencies(array(Events_Watches=>array(Watches)) ?

or

R::dependencies(array(Events=>array(Watches))  ?

I want RB to cascade delete the records out of the Events_Watches table when I trash() a Watch that has events associated with it.  Many thanks.

Mike

cslinuxboy

unread,
Jan 3, 2013, 4:56:09 PM1/3/13
to redbe...@googlegroups.com
Gabor,

     Great!  Thanks for the info.  Sorry for the late reply.

Mike

cslinuxboy

unread,
Jan 4, 2013, 10:25:07 PM1/4/13
to redbe...@googlegroups.com
Gabor,

     I deleted a bean that had a shared list by using R::trash($bean).  It deleted the bean entry from the database but not the shared list entries in the N:M table.  From your post I understood it to meant that RB would remove the shared list db entries also when their dependent bean was deleted.  Should I still run array_shift for each shared entry also to unset them?  Thanks.

Mike

On Saturday, November 10, 2012 5:10:13 AM UTC-7, gabor wrote:
Reply all
Reply to author
Forward
0 new messages