cake-php@googlegroups.com
[Top] [All Lists]

find('list') with conditions of joined tables? --psybear

Subject: find('list') with conditions of joined tables? --psybear
From: psybear83
Date: Thu, 16 Dec 2010 10:11:50 -0800 PST
Hey everybody

I want to use find('list') that uses conditions of joined tables. But
it seems find('list') doesn't support that?

Example: I have a model User which hasOne UserProfile.

$userProfile->find('all', array(
            'conditions' => array(
            )
          ));

...works like a charm, but...

$userProfile->find('list', array(
            'conditions' => array(
              'User.id' => $id
            )
          ));

...tells me:

SQL Error: 1054: Unknown column 'User.id' in 'where clause' [CORE/cake/
libs/model/datasources/dbo_source.php, line 684]

Query: SELECT `UserProfile`.`id` FROM `user_profiles` AS `UserProfile`
WHERE `User`.`id` = 1102

Evidently it doesn't join the hasOne table by itself... Is there a way
to force it to do it anyway?

Thank you
Josh

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@xxxxxxxxxxxxxxxx
To unsubscribe from this group, send email to
cake-php+unsubscribe@xxxxxxxxxxxxxxxx For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

<Prev in Thread] Current Thread [Next in Thread>