Re: SELECT DISTINCT using find('list')

2008-11-06 Thread [EMAIL PROTECTED]

I see, I'll try that and post the results, thanks!

On Nov 6, 10:36 am, teknoid <[EMAIL PROTECTED]> wrote:
> find('list') requires to fields, because it is used to build a select
> drop down (with value being the id, and option the name usually).
> You probably need find('all') + Set::extract() ... depending on what
> you need really.
>
> On Nov 6, 10:44 am, "[EMAIL PROTECTED]"
>
> <[EMAIL PROTECTED]> wrote:
> > Hello guys,
>
> > I need a "distinct" list of items, so that I tried to set this up
> > using the following code, but it's not working:
>
> > $list = $this->Model->find('list',array('fields' => 'DISTINCT
> > `Model`.`field`', 'conditions' => array("Model.field2 !=
> > '-1'"),'order' => 'Model.order ASC'));
>
> > Unfortunately the result query is this:
>
> > SELECT `Model`.`field`, DISTINCT `Model`.`field` FROM `models` AS
> > `Model` WHERE `Model`.`field2` != '-1' ORDER BY `Model`.`order` ASC
>
> > Which is not what I need, there's an extra `Model`.`field`, that
> > breaks the query. Do you have an idea of how to get the results I'm
> > looking for?
>
> > Thanks in advance
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: SELECT DISTINCT using find('list')

2008-11-06 Thread teknoid

find('list') requires to fields, because it is used to build a select
drop down (with value being the id, and option the name usually).
You probably need find('all') + Set::extract() ... depending on what
you need really.

On Nov 6, 10:44 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Hello guys,
>
> I need a "distinct" list of items, so that I tried to set this up
> using the following code, but it's not working:
>
> $list = $this->Model->find('list',array('fields' => 'DISTINCT
> `Model`.`field`', 'conditions' => array("Model.field2 !=
> '-1'"),'order' => 'Model.order ASC'));
>
> Unfortunately the result query is this:
>
> SELECT `Model`.`field`, DISTINCT `Model`.`field` FROM `models` AS
> `Model` WHERE `Model`.`field2` != '-1' ORDER BY `Model`.`order` ASC
>
> Which is not what I need, there's an extra `Model`.`field`, that
> breaks the query. Do you have an idea of how to get the results I'm
> looking for?
>
> Thanks in advance
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



SELECT DISTINCT using find('list')

2008-11-06 Thread [EMAIL PROTECTED]

Hello guys,

I need a "distinct" list of items, so that I tried to set this up
using the following code, but it's not working:

$list = $this->Model->find('list',array('fields' => 'DISTINCT
`Model`.`field`', 'conditions' => array("Model.field2 !=
'-1'"),'order' => 'Model.order ASC'));

Unfortunately the result query is this:

SELECT `Model`.`field`, DISTINCT `Model`.`field` FROM `models` AS
`Model` WHERE `Model`.`field2` != '-1' ORDER BY `Model`.`order` ASC

Which is not what I need, there's an extra `Model`.`field`, that
breaks the query. Do you have an idea of how to get the results I'm
looking for?

Thanks in advance

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---