Hi all,

I've got a bit of a query, I have a relationship between a User and an
object I'm modelling whereby
a user may have an image associated which them as follows:

class User {

       // Define relationship with images with object_id as the key in
images
       var $hasMany = array('photographs' => array('className' => 'Image',
                                                    'foreignKey' =>
'object_id',
                                                    'dependant' => true));
}

What do I do if the image does not exist in terms of the relationship.  At
the moment, I'm calling
unbindModel, as follows, before retrieving the user object:

$this->User->unbindModel( array('hasMany' => array('Image')) );
$this->User->findByEmail($email));

but I want this to be conditional.  i.e. I only want to unbind the
association if no image exists.
Is there an easy way to do this?

the only way I can think of is to retrieve the user as above, then do a
Image->findByUserId
and check that the image returned is not null.  Sounds a bit odd to me...

Many thanks,
Jon.

-- 
Web: http://www.jonathanholloway.co.uk
Mail:   [EMAIL PROTECTED]
Mobile:  07968 902140, 07976 125367
IM:        [EMAIL PROTECTED]

--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to