Monday, February 1, 2010

Distinct in find('list')

I'm using a DISTINCT in a find('list') because I need to do an inner
join, but the key don't show up in the result.

My query is:

$sources = $this->find('list', array(
'fields' => array('DISTINCT Source.id', 'Source.name'),
'conditions' => array('agglomeration_id' => $agglomeration),
'joins' => array(array(
'table' => 'data_quantities',
'alias' => 'Quantity',
'type' => 'INNER',
'conditions'=> array('Quantity.source_id = Source.id')
)),
'order' => array('sort','name'),
)
);

and the result is:

Array
(
[] => Résidentiel
)

Any suggestion?

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@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: