On Oct 6, 8:44 pm, Brenton B <[EMAIL PROTECTED]> wrote:
> uh ... k ...
>
> So for models there's the "find" function, whose first parameter can
> be an assortment of strings depending on what you want to find ...
> well, one of the ones I'm using is "list", which will generate a list
> that's for easier usage in a select list.
> Then there's also the possibility of an array of options as the second
> parameter. One of these possible options is the "contain" key, which,
> when used, would denote what associations to use while doing the find.
> This option doesn't seem to take affect when I use it in conjunction
> with `find('list')`.
> Another thing you an do with the second 'options' array parameter is
> declare how you want the list returned, and what it is to be grouped
> by, for the select list.
>
> In my case, I have a list of States ... I want them grouped by Country
> name .... Therefore, I'm calling it like this:
>
>                         $states = $this->User->State->find('list',
>                                                                 
> array('contain' => array('Country'),
>                                                                         
> 'fields' => array('State.id', 'State.name', 'Country.name')
>                                                                 ));
>
> However, it barks and complains that "Warning (512): SQL Error: 1054:
> Unknown column 'Country.name' in 'field list'", which is because
> 'Country' isn't included int he query ("Query: SELECT `State`.`id`,
> `State`.`name`, `Country`.`name` FROM `states` AS `State`   WHERE 1 =
> 1   ORDER BY `State`.`name` ASC  "), because (I'm assuming) "contain"
> does not work.
>
> If I do `find('all')` (with everything else being the same), it
> returns without error ... albeit, completely screwed up for the select
> list .... if I do 'State.country_id' for the "group" field (3rd in the
> 'fields' array), it returns without error, albeit using the id and not
> the name for the group.
>
> Details added.
>
> Confused or understood?

Apparently you weren't expecting a reply in the same tone as the
question.
Is this on purpose?

Find list has a default recursive level of -1
https://trac.cakephp.org/browser/branches/1.2.x.x/cake/libs/model/model.php#L1937

AD
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to