The example in the manual is a little misleading. It assumes a belongsTo relationship between Post and Author (i.e. Post belongsTo Author). In that case a JOIN will be performed (remember, JOINs are only done for hasOne and belongsTo).
I think the confusion is that it also mentions a hasMany relationship (i.e. Author hasMany Post), but in that case the JOIN is not forced. So, in other words, if you assumed that in the manual example there would be a call: $this->Post->find(... then a JOIN is performed and everything works as expected. If, however, it was $this->Author- >find(... then one would likely to see an error similar to yours. P.S. I've submitted a correction to the manual. On Aug 19, 8:16 pm, Christian <[EMAIL PROTECTED]> wrote: > In the manual I found an example of what I'm trying to do, except it > doesn't work... > > --------------------------------------------------------------------------------------------------------------------------------------------- > Let's say you had a hasMany/belongsTo relationship between Posts and > Authors, which would result in a LEFT JOIN. Let's say you wanted to > find all the posts that contained a certain keyword (“magic”) or were > created in the past two weeks, but you want to restrict your search to > posts written by Bob: > > code: > array ( > "Author.name" => "Bob", > "or" => array ( > "Post.title LIKE" => "%magic%", > "Post.created >" => date('Y-m-d', strtotime("-2 weeks")) > ) > ) > --------------------------------------------------------------------------------------------------------------------------------------------- > So you pass that as conditions to your find() call. > > I have a Game model and a GamePlayer model. > Game hasMany GamePlayer. > GamePlayer belongsTo Game. > I want to find all games with inherent Game.status=1, and with an > associated GamePlayer.user_id=1 > > $cond = array("conditions"=>array("Game.status"=>1)); > $games = $this->Game->find('all',$cond)); > > --> This will return all the games with status=1, and right underneath > the associated GamePlayers > > however, when i say.. > $cond = > array("conditions"=>array("Game.status"=>1,"GamePlayer.user_id"=>1)); > and repeat the find... > > it spits back at me "Unknown column 'Game.status' in 'where clause'" > because it doesn't do a JOIN like the example from the cookbook says. > > I know this topic has come up on the google group elsewhere, but they > either don't address this exact issue, or i try what is suggested and > still no luck. > I'd like to think this is a pretty basic and overused query for almost > any application of databases. > > thanks, > > Christian --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---