my models:
user hasmany comment
profile hasmany comment
user hasone profile
user hasone photo
comment belongsto user
profile belongsto user
photo belongsto user
what im trying to do is pull up profile information and the profiles
comments.
here is my index() and its find():
function index($url = null) {
$this->Profile->recursive = -1;
/*
*
*/
$profile = $this->Profile->find('first', array(
'conditions' => array('Profile.url' => $url),
'contain' => array(
'User' => array(
'fields' => array(
'User.id','User.name'
),
'Photo' => array(
'fields' => array(
'Photo.thumbnail','Photo.image'
)
)
),
'Comment' => array(
'User' => array(
'fields' => array(
'User.name'
),
'Photo' => array(
'fields' => array(
'Photo.thumbnail'
)
)
)
)
)
));
$this->set('profile', $profile);
}
this function takes its function arg and finds the appropriate profile
ie. /profiles/index/centroscape
Everything returns correctly without error i get exactly what i want,
but once the query gets to the Photo part, it queries multiple times
for photos with different ids. if there is a way to avoid 1 query per
photo please let me know. I dont think there is.
imagine a profile with 50-80 comments. its kind of scary. also, this
is my first time implementing containable behavior. any tips other
than my question are welcome!
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---