Re: Basic Question: Refining Queries

2008-01-20 Thread Chris Wade
Here's what I eventually did: $userArray = $this->User->find('User.id='.$this->User->id, null, null, 1); $this->set('data', $userArray); foreach($userArray['Friends'] as $friend) { $friendIds[] = $friend['id']; $friendConditions = array('Profile.user_id' => $friendIds); $this->set('f

Re: Basic Question: Refining Queries

2008-01-19 Thread Chris Wade
A little more information. I've tried the following: $this->set('friends', $this->User->Friends->findall('user1_id='.$this- >User->id)); SQL Error: 1054: Unknown column 'user1_id' in 'where clause' $this->set('friends', $this->User->Friends- >findall('Friends.user1_id='.$this->User->id)); SQL Er

Re: Basic Question: Refining Queries

2008-01-19 Thread Chris Wade
Ah, Chaining was the word I was looking for, but I was thinking that it would give you only the records from the chained models that were related to the model of the controller you were in. Thanks for the info. So, to do something like what I want to do, I would have to say $this- >User->Friends

Re: Basic Question: Refining Queries

2008-01-19 Thread Dardo Sordi Bogado
Chaining isn't bad, but it only gives you a reference for the model, it doesn't set any conditions. You have to pass them manually to the findAll(). You can unbind() the models you don't want to get on the findAll and set the recursion level that fits your needs. Also it is possible to set condit

Re: Basic Question: Refining Queries

2008-01-18 Thread the_woodsman
Hi, I'm not sure I fully understand your problem, but: > I'd like to figure out how to do something like: > $this->set('friends', $this->User->Friends->Profiles->findAll()); > This returns every profile in the system, not just those for the > user's friends. Your controller isn't tied to using

Basic Question: Refining Queries

2008-01-18 Thread Chris Wade
Hi All, I'm building my first site with cake, and am working my way through the documentation, but so far this part is confusing. I've got a page that shows a user's profile, the avatars of the user's "friends," blog posts by the user, the number of comments for each blog post, and comments by o