Try setting the $model->recursive = 1;
On Thu, Aug 28, 2008 at 1:24 AM, Christian <[EMAIL PROTECTED]> wrote:
>
> Thanks for the help so far, Martin.
>
> Sadly.. it just won't go!
> I've cleaned the cache, reinstalled a fresh/latest version of cake
> 1.2, made every little naming convention/association explicitly.. but
> no avail.. same problem. It just puts the Game.status=1 into the WHERE
> clause with no join.
>
> in a mysql terminal, i can say "select * from game_players join games
> where game_players.id=1 AND games.status=1;" and it will return me
> what i want with no error
>
> Would it trouble you, or anyone, to give me a chunk of sample code, or
> their own stripped down code of model/controllers that are 'belongsTo'
> associated that result in a working join?
> There has to be something ridiculous or stupid that I'm not doing.
>
> I refuse to resort to a custom query for such simple functionality!
> Christian
>
> On Aug 25, 4:40 am, "[EMAIL PROTECTED]"
> <[EMAIL PROTECTED]> wrote:
>> I set my Debug to 2 to have a look at when Cake does joins in my app.
>> hasOne does a JOIN
>> belongsTo does a JOIN
>> hasMany just selects on the related table with a WHERE clause
>> HABTM does a few queries and things.
>>
>> So, like you say, your find should work from $this->GamePlayer->find()
>> since it belongs to a Game.
>>
>> This is all I can think of (all extreme longshots):
>> Trash all cache files. (in case Cake reads the schema form cache and
>> it is not up to date)
>> Download Cake again (just to make sure you are not running a nightly
>> with a bug in it of some really rare problem with the files)
>> Change the name of the "missing" field in MySQL. (No rational reason
>> for doing this really)
>> Make the association very explicit and define all the parameters you
>> can for Game (in case something does not match Cakes conventions)
>>
>> good luck to you
>> /Martin
>>
>> On Aug 21, 11:54 pm, Christian <[EMAIL PROTECTED]> wrote:
>>
>> > Sorry, my mistake. A lot of tinkering and testing i copied the wrong
>> > things
>> > Game->find() says it can't find GamePlayer.user_id column which makes
>> > sense now because it doesn't do a join.
>>
>> > however still having the problem where GamePlayer->find() says it
>> > can't find Game.status column, so still no join.
>>
>> > my setup is as follows (i just verified to make sure i didn't slip up
>> > on simple naming):
>>
>> > class GamePlayer extends AppModel {
>> > var $name = 'GamePlayer';
>> > var $belongsTo = array (
>> > 'User',
>> > 'Game'
>> > );
>>
>> > }
>>
>> > database_name (columns):
>> > games (id int(10) unsigned, status int(1),...)
>> > game_players (id int(10) unsigned, game_id int(11),...)
>>
>> > another point, I'm doing this find() from within the games_controller.
>> > However i do have var $uses = array('Game','User','GamePlayer',
>> > 'Rule', 'Weapon'); in the controller...
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---