Tuesday, February 2, 2010

Re: Distinct in find('list')

What is your expected result?
I want to know why you want to use an inner join to data_quantities -
is it because you only want those records from the sources, for which
exists data_quantities?

Have you tried without distinct and do you get the wrong result?
Enjoy,
John

On Feb 2, 1:06 am, lemp <goo...@forgenumerique.com> wrote:
> 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: