Re: Containable on deep pagination records
You want a self join. Try something along these lines: class FriendOfFriend extends AppModel { public $name = 'FriendOfFriend'; public $belongsTo = array( 'User' => array( 'className' => 'User', 'foreignKey' => 'user_id' ) ); public $hasMany = array( 'Friend' => array( 'className' => 'Friend', 'foreignKey' => 'friend_id' ) ); } public $paginate = array( 'Friend' => array( 'limit' => 10, 'order' => array('Friend.requestTime' => 'ASC'), 'recursive' => 2, 'contain' => array( 'FriendOfFriend' => array( 'User' => array( 'Country' ) ) ) ) ); On Thu, Jan 8, 2009 at 6:17 PM, Miles J wrote: > > Anyone have an idea on this? > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Containable on deep pagination records
Anyone have an idea on this? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Containable on deep pagination records
Hmmm it seems once I moved my custom pagination method, it worked... but now im getting 55+ queries. They all look like this, anyway to shorten it? Its double querying the User/Member data. 2 SELECT COUNT(*) AS `count` FROM `friends` AS `Friend` LEFT JOIN `users` AS `User` ON (`Friend`.`user_id` = `User`.`id`) LEFT JOIN `users` AS `Member` ON (`Friend`.`friend_id` = `Member`.`id`) WHERE `Friend`.`status` = 'approved' AND ((`Friend`.`user_id` = 2) OR (`Friend`.`friend_id` = 2)) 1 1 1 3 SELECT `Friend`.`id`, `Friend`.`user_id`, `Friend`.`friend_id`, `Friend`.`status`, `Friend`.`requestTime`, `User`.`id`, `User`.`username`, `User`.`handle`, `User`.`quote`, `User`.`country_id`, `User`.`signupDate`, `Member`.`id`, `Member`.`username`, `Member`.`handle`, `Member`.`quote`, `Member`.`country_id`, `Member`.`signupDate` FROM `friends` AS `Friend` LEFT JOIN `users` AS `User` ON (`Friend`.`user_id` = `User`.`id`) LEFT JOIN `users` AS `Member` ON (`Friend`.`friend_id` = `Member`.`id`) WHERE `Friend`.`status` = 'approved' AND ((`Friend`.`user_id` = 2) OR (`Friend`.`friend_id` = 2)) ORDER BY `Friend`.`requestTime` ASC LIMIT 10 10 10 2 4 SELECT `User`.`id`, `User`.`username`, `User`.`handle`, `User`.`quote`, `User`.`country_id`, `User`.`signupDate` FROM `users` AS `User` WHERE `User`.`id` = 2 1 1 1 5 SELECT `Country`.`id`, `Country`.`name`, `Country`.`iso`, `Country`.`locale_id` FROM `countries` AS `Country` WHERE `Country`.`id` = 1 1 1 1 . 42 SELECT `Member`.`id`, `Member`.`username`, `Member`.`handle`, `Member`.`quote`, `Member`.`country_id`, `Member`.`signupDate` FROM `users` AS `Member` WHERE `Member`.`id` = 241 1 1 43 SELECT `Country`.`id`, `Country`.`name`, `Country`.`iso`, `Country`.`locale_id` FROM `countries` AS `Country` WHERE `Country`.`id` = 1 1 1 1 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Containable on deep pagination records
So I have this pagination setup using containable, but the contain isn't working, suggestions? var $paginate = array( 'Friend' => array( 'limit' => 10, 'order' => array('Friend.requestTime' => 'ASC'), 'recursive' => 2, 'contain' => array( 'Member', 'User' => array('Country') ) ) ); Friend model has two foreign ids (user_id, friend_id), both of which point to the user model. So respectively I called them User and Member (cant do friend because thats the current model). Anyways the user model has a belongsTo to a country, and thats what im trying to contain. But at the moment im getting all the related information return, not even basic containables is working. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---