Yes for all of the below. I use contain throughout the app with no problems anywhere except the User <=> Profile
But I have no recursive set though. All my finds are done thru functions, nothing is read() Everything works fine getting Profile User data when contained in other models when I pull for example SomeModel contain array(User => array (Profile)) gets me SomeModel info along with the User and Profile -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Tonu Tusk Sent: December-14-09 6:21 AM To: CakePHP Subject: Re: Contain Help Hi Dave, - have you made sure that your User model has var $actsAs = array('Containable'); in its class? - are you setting 'recursive' to a value lower than 1 as a default for your User model? (it will only work with a recursive value >= 1) - Have you set your related fields in your Profile table (i.e user_id) - Have you defined your relationships correctly in your User and Profile models? cheers On Dec 14, 6:29 am, John Andersen <[email protected]> wrote: > Hi Dave, > > Try changing this: > > [code]> 'contain' => array( > > 'Profile' => array( > > 'conditions' => array( > > 'Profile.id' => $auth_id))) > > [/code] > > into this: > > [code]> 'contain' => array('Profile') > > [/code] > > CakePHP should be able to identify the correct Profile by the model > relationships that you have specified. > Enjoy, > John > > On Dec 14, 2:27 am, "Dave" <[email protected]> wrote: > > > Contain is not grabbing my related model and I don't know why. Tried > > with fields or without and still nothing. > > > public function getUser($auth_id) > > > { > > $params = array( > > 'conditions' => array( > > 'User.id' => $auth_id), > > 'fields' => array( > > 'User.firstname', > > 'User.lastname', > > 'User.username', > > 'User.email', > > 'User.slug', > > 'User.id', > > 'User.reset', > > 'User.confirm_code'), > > 'contain' => array( > > 'Profile' => array( > > 'conditions' => array( > > 'Profile.id' => $auth_id))) ); > > $data = $this->find('first', $params); > > return $data; > > > } > > > Relation: > > User model > > > var $hasOne = array( > > 'Profile' => array( > > 'className' => 'Profile', > > 'foreignKey' => 'id', > > 'dependent' => false > > ) > > ); > > > The Profile.id is the same as User.id > > > Any ideas or help would be great. > > > thanks > > > Dave Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+at http://groups.google.com/group/cake-php?hl=en No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.716 / Virus Database: 270.14.102/2556 - Release Date: 12/13/09 04:09:00 Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
