Friday, February 24, 2012

find list => distinct?

Hi,

I have this query:
$results = $this->find('list', array(
'conditions' => array('1 = 1'),
'fields' => 'REG_ID, REG_NAME',
'order' => array('REG_NAME ASC')
));

and I do a
echo $this->Form->input('city', 'options' => $getCities, 'id' =>
'city'));

to get a beautyful list but the statement is kind of wrong as it does
this:
SELECT `Objekt`.`REG_ID`, `Objekt`.`REG_NAME` FROM
`mine`.`DetailObjekt` AS `Objekt` WHERE 1 = 1 ORDER BY `REG_NAME` ASC

Which returns me all listings I have, currently 1632 items.

Before I used a find ('all') and set fields => DISTINCT OBI_ID

But a DISTINCT is not allowed in find('list') ?
Is there anyhow a trick to query distinct?

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


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

No comments: