Have a look at the query it generates (set debug to 2) , I'm sure this will
shine a bright light on the problem ...

On Mon, Sep 28, 2009 at 9:48 PM, bram <[email protected]> wrote:

>
> In my app, I have a User model that has a habtm association with
> 'Event'. In one of the views, I want to show a list of Users and their
> most recent event.
>
> I ended up with this definition in the User model:
>
>        var $hasAndBelongsToMany = array(
>                'Event' => array(
>                        'className' => 'Event',
>                        'joinTable' => 'events_users',
>                        'foreignKey' => 'user_id',
>                        'associationForeignKey' => 'event_id',
>                        'unique' => true,
>                        'limit' => 1,
>                        'order' => 'Event.date DESC'
>                )
>        );
>
> find('all') returns the list of all users and only one of them has an
> associated event.
>
> When increasing the limit, it does show associated events, but when
> some user don't have events associated, some other users will have
> multiple events returned.
>
> Is this a cake bug or do I have the wrong impression of the limit in a
> habtm association?
>
> Cheers,
>
> Bram
> >
>

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

Reply via email to