On Jun 12, 8:49 pm, calvin <cal...@xxxxxxxxxxxxxxxxx> wrote:
> Ah, I misunderstood you. I think you should be able to just use the
> 'join' and 'group' keys, e.g.:
> $countries = $this->Country->find('list', array(
> 'joins' => array(
> 'table' => 'cake_members',
> 'alias' => 'Member',
> 'type' => 'inner',
> 'foreignKey' => 'Member.country_id'
> 'group' => array('Country.id')
> I think that should work. Or you may need to use the 'conditions'
> parameter in the 'joins' array instead of the 'foreignKey' parameter.
> Unfortunately, the 'joins' parameter is not documented in the Cookbook
> for find(). It's only mentioned in the subQuery example using
> buildStatement(), but that's not necessary.
Thanks. I did try mucking about with the joins option but nothing was
working for me. I think I had the syntax wrong but I probably had
other errors, too. This looks correct to me after cross-checking
elsewhere, but still no joy. Here's my method using your example:
public function getActiveCountries()
'joins' => array(
'table' => 'members',
'alias' => 'Member',
'type' => 'inner',
'foreignKey' => 'Member.country_id'
'group' => array('Country.id')
Warning (512): SQL Error: 1054: Unknown column 'Array' in 'on
clause' [CORE_1.2.7/cake/libs/model/datasources/dbo_source.php, line
Query: SELECT `Country`.`id`, `Country`.`name` FROM `countries` AS
`Country` inner JOIN members AS `Member` ON (Array) WHERE 1 = 1 GROUP
The syntax looks good to me. The joins option should be an array with
a separate array for each join. I'm going to dive back into the model
and dbo_* classes to see if I figure it out.
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
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