hi,
I am getting weird problem with belongsTo. My database models
following relationships
articles <---- HABTM ---> users
articles_users ---> belongsTo --> articles && articles --> hasMany --
> articles_users
articles_users ---> belongsTo --> users && users --> hasMany -->
articles_users
Below is how I have defined belongsTo relations in articles_users
var $belongsTo = array('Article','User');
this is the simple piece of code that I am trying to get it working
but is not. Based on the userid provided, it determines the username
of the user
//defined in articles_users_controller.php
function test($userid){
$this->ArticlesUser->expects('User');
$this->ArticlesUser->User->expects();
$result = $this->{$this->modelClass}->User->findAll(array('User.id'
=> "{$userid}"), array('User.username', 'User.id'));
debug($result);
exit();
}
however, the SQL query that is being generated is
SELECT `User`.`username`, `User`.`id` FROM `articles_users` AS
`ArticlesUser` WHERE `User`.`id` = 2
If I change the $belongsTo relationship to only contain 'User' i.e.
var $belongsTo = array('User');
then the above method works...I have tried everything that I can think
of..but nothing is working..
Please let me know if you bakers have any idea or faced similar
situation..
Regards,
Ritesh
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---