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 [email protected]
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
-~----------~----~----~----~------~----~------~--~---