just tried it (setting dependent=true) and deleting the post also deleted
all the comments

On Wed, May 20, 2009 at 6:10 PM, JamesF <[email protected]> wrote:

>
> @andrew will that do all the work automagically?
>
> On May 20, 9:04 pm, Andrew McCafferty <[email protected]>
> wrote:
> > In your Post model set the dependent key to true on the hasMany
> > relationship.
> >
> > var $hasMany = array(
> >                 'Comment' => array(
> >                         'className' => 'Comment',
> >                         'foreignKey' => 'post_id',
> >                         'dependent' => true,
> >                 )
> >         );
> >
> > On 20 May, 23:45, Jorge Garifuna <[email protected]> wrote:
> >
> > > Thank you for the update.
> >
> > > Is there a way that cakePHP can handle this internally?
> >
> > > On Wed, May 20, 2009 at 2:18 PM, harrzack <[email protected]>
> wrote:
> >
> > > > If you use the InnoDB engine, you can set up proper relationships.
> You
> > > > have a Foreign key in the child tables that ties it to the Parent
> > > > table. There are Constraints set to the  built into the InnoDB that
> > > > you set for ON DELETE and ON UPDATE, and when the Parent is deleted,
> > > > there is a cascade to delete all children.
> >
> > > >  Read here:
> > > >
> http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints...
> >
> > > > On May 20, 2:48 pm, Jorge Garifuna <[email protected]> wrote:
> > > > > I just deleted a post with comments and the comments related to
> that
> > > > > post were not deleted (left as orphan records).
> >
> > > > > Is there a way to delete related records when the master gets
> deleted,
> > > > > so they wont be left as orphan records?
> >
> > > > > Thanks,
> >
> > > > > Jorge
> >
> > > --
> > > Jorge Garifuna
> > > Professional Web Developer
> > > "Your Web Solution Partner"
> > > Garinet Media Network, LLC.
> > > 811 Wilshire Blvd. Suite 1705
> > > Los Angeles, CA 90017http://www.GariDigital.com
> > > Business Operating Hours: Monday - Friday: 9AM - 6 PM PST
> >
>


-- 
Jorge Garifuna
Professional Web Developer
"Your Web Solution Partner"
Garinet Media Network, LLC.
811 Wilshire Blvd. Suite 1705
Los Angeles, CA 90017
http://www.GariDigital.com
Business Operating Hours: Monday - Friday: 9AM - 6 PM PST

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to