> I would turn DEBUG to 2 and see what the sql queries are.
I did, but I didn't post it, sorry.
When using the bindModel() method, Cake makes a query for every(!)
submission and adds the defined condition in the where clause -- but returns
the record (with an empty User array) in any case, e.g.:
SELECT `User`.`id`, `User`.`role_id`, `User`.`gender_id`, `User`.`company`,
`User`.`title`, `User`.`firstname`, `User`.`lastname`, `User`.`nickname`,
`User`.`email`, `User`.`password`, `User`.`active`, `User`.`created`,
`User`.`modified`, `User`.`sessionexpires` FROM `users` AS `User` JOIN
`submissions_users` ON `submissions_users`.`submission_id` = '70' AND
`submissions_users`.`user_id` = `User`.`id` WHERE
(`submissions_users`.`user_id` = 2)
Heiner
>
> 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
-~----------~----~----~----~------~----~------~--~---