Im having problems getting pagination working. I have complex custom
queries and I just cant get it working correctly. Ive tried building a
custom paginate() method within the model that does additional
filtering, but then I also feel limited using the $paginate var in the
controller.

Anyone have suggestions here?

This is the method im trying to turn into paging (cant seem to get the
$user_id and $status passed in (its dynamic of course):

function getMyFriends($user_id, $status = 'approved', $limit = 5) {
        $friends = $this->find('all', array(
                'fields' => array('Friend.*'),
                'recursive' => -1,
                'conditions' => array(
                        'Friend.status' => $status,
                        'OR' => array(
                                'Friend.user_id' => $user_id,
                                'Friend.friend_id' => $user_id
                        )
                ),
                'order' => 'Friend.requestTime ASC',
                'limit' => $limit
        ));

        $cleanFriends = array();
        if (!empty($friends)) {
                foreach ($friends as $friend) {
                        if ($friend['Friend']['friend_id'] != $user_id) {
                                $friend_id = $friend['Friend']['friend_id'];
                        } else {
                                $friend_id = $friend['Friend']['user_id'];
                        }

                        $userObj = $this->User->find('first', array(
                                'fields' => array('User.id', 'User.username', 
'User.avatar',
'User.handle', 'User.country_id', 'User.signupDate'),
                                'recursive' => -1,
                                'conditions' => array('User.id' => $friend_id)
                        ));

                        if (!empty($userObj)) {
                                $cleanFriends[] = array_merge($friend, 
$userObj);
                        }
                }
        }

        return $cleanFriends;
}

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to