This is done for you, if you're using expanded version of the $hasMany
member variable.

For example, your Group model might contain the following declaration:


        var $hasMany = array(
                'User' => array(
                        'classname' => 'User',
                        'conditions' => '',
                        'order' => '',
                        'dependent' =>  true,
                        'foreignKey' => 'company'),
                );

You'll see that 'dependent' = true. This means that if the group is
deleted, the associated users will be deleted. I'm pretty sure that
this is false by default, so if you're using the single-line $hasMany
declaration, like this:

        var $hasMany = array('User');

Then I don't think dependency (called 'cascades') is turned on. For me,
single-line declarations don't work (because I've not stuck to the Cake
naming conventions, like an idiot!) so this is how I implement all of
my hasXXX associations - the long-winded way.

HTH
James

On Oct 5, 6:26 am, "maestro777" <[EMAIL PROTECTED]> wrote:
> I have a table called Groups which is associated on a "one to many"
> with another table called Users. Is there an efficient way of deleting
> records in the Users table that are link to the one record being
> deleted in the Groups table? I couldn't find a
> model->delete('condition') in the API. I think this should be a common
> situation, and I just wonder how you guys accomplish it.
> 
> Thanks in advance for your response.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply via email to