I would turn DEBUG to 2 and see what the sql queries are.

Sam D

On 7/22/06, kitten <[EMAIL PROTECTED]> wrote:
>
> Hi :)
>
> I stumbled over a problem with HABTM association that seemed trivial at
> first but I could not find a real solution...
>
> I have a HABTM association between model "User" and model "Submission". Each
> submission "belongs" to one or more users, each user can be associated with
> one or more submissions.
>
> I want to show a list of submissions -- but only those that are associated
> with a certain user.
>
> I first tried:
>
> $sqlCond = array('User.id' => 2);
> $submissions = $this->Submission->findAll($sqlCond);
>
> I get the error: Unknown table 'User' in where clause.
>
> Looking at the where clause of the query, this seems normal: there is no
> JOIN with the user table (independantly from the setting of
> $this->Submission->recursive).
>
>
> Then I tried:
>
> $aBindings = array(
>     'hasAndBelongsToMany' => array(
>         'User' => array(
>             'conditions' => array('User.id' => 2),
>         )
>     )
> );
> $this->Submission->bindModel($aBindings);
> $this->Submission->findAll();
>
> Here I get back _all_ submissions, the conditions array is ignored. I have
> the feeling that I am overseeing something obvious...
>
> Right now, I make a custom query with $this->Submission->query() -- but I
> think there probably is (or should be) a Cake way for for doing this?!
>
> Any thoughts?
>
> Heiner
>
>
>
> >
>

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

Reply via email to