hi

okie now its working..I tried couple of things and it seems, changing
the order of array in belongsTo definition helped. It seems, CakePHP
recursively initialize model and somehow with my original order, User
object was never getting created

Regards,
Ritesh

On May 23, 7:32 pm, bingo <[EMAIL PROTECTED]> wrote:
> hi,
>
> I did some debugging and found some weird things..
> if I do debug($this->ArticlesUser->User) it returns me ArticlesUser
> object instead of User Object
>
> however I do the same in another class (discussions_controller.php)
> that also has a belongsTo relationships with User returns User
> Object...
>
> Any idea where in the code, I might be making a mistake
>
> Regards,
> Ritesh
>
> On May 23, 3:43 pm, bingo <[EMAIL PROTECTED]> wrote:
>
>
>
> > 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- Hide quoted text -
>
> - Show quoted text -


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to