Re: How would I write this query

2008-12-27 Thread gearvOsh
This is what I came up with, I dont know if theres another solution. Also im completely lost how to paginate this. function getMyFriends($user_id, $status = 'approved', $limit = 5) { $friends = $this->find('all', array( 'fields' => array('Friend.*')

Re: How would I write this query

2008-12-27 Thread gearvOsh
I got something working on this but I ran into a problem. When joining the user table to the friend data, I dont know if its the friend_id or the user_id. So I will have to do some filtering and extra queries after i grab all friends. --~--~-~--~~~---~--~~ You recei

Re: How would I write this query

2008-12-27 Thread Arthur Pemberton
Assuming that translates to: SELECT Friend.*, User.username, User.avatar, User.handler FROM friends AS Friend, INNER JOIN users AS User ON User.id = Friend.user_id WHERE Friend.status = 'approved' AND ( (Friend.user_id = ':us

Re: How would I write this query

2008-12-27 Thread gearvOsh
Snippets of the code: CREATE TABLE IF NOT EXISTS `friends` ( `user_id` int(10) unsigned NOT NULL, `friend_id` int(10) unsigned NOT NULL, `status` enum('approved','pending') NOT NULL default 'pending', `requestTime` int(10) NOT NULL, KEY `user_id` (`user_id`), KEY `friend_id` (`friend_

RE: How would I write this query

2008-12-27 Thread Steven Wright
What do your tables, models and controllers look like? -Original Message- From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf Of gearvOsh Sent: Saturday, December 27, 2008 7:48 PM To: CakePHP Subject: How would I write this query Im a bit new to the model s