Tuesday, April 16, 2013

Re: find all users from another table

thanks david,... 
I actually solve this problem with $this->PhotoLike->find('all',... 
My PhotoLike Model belongsTo 
'User' => array('className' => 'User', 'foreignKey'    => 'user_id'), 

and I have a Profile helper that brings profile pictures and user data  to show up in a views,... 



On Monday, April 15, 2013 11:10:53 PM UTC-7, david...@gmail.com wrote:
Since you are calling find the first time with 'list' it is returning the array as you state.  However, you are trying to index into that array with an index of 'PhotoLike' which doesn't exist in that array.  So the error message is correct.

I believe that the second find should be
find('all', array('conditions' => array('User.id' => $photo_likes)))

This should generate a WHERE clause of WHERE 'User.id' in (59, 48) which is what you want.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: