Looks like it's fixed in the latest branch, but not in the beta:

https://trac.cakephp.org/changeset/6360/branches/1.2.x.x/cake/libs/model/model.php

On Jan 22, 2:20 pm, ianh <[EMAIL PROTECTED]> wrote:
> Looking at the code thats what I thought it would do to (using the 1.2
> beta) but my unit tests say that, when trying to generate a list of
> events.url => events.name - this doesn't work:
>
> return $this->find
> (
>         'list'
>         , array
>         (
>                 'conditions' => $conditions
>                 , 'order' => 'Event.eventdate DESC'
>                 , 'fields' => array('{n}.Event.url', '{n}.Event.name')
>                 , 'recursive' => 0
>         )
> );
>
> whereas this works correctly:
>
> $this->primaryKey = 'url';
> return $this->find
> (
>         'list'
>         , array
>         (
>                 'conditions' => $conditions
>                 , 'order' => 'Event.eventdate DESC'
>                 , 'fields' => array('Event.url', 'Event.name')
>                 , 'recursive' => -1
>         )
> );
>
> Hmmm - thinking cap time. And re the original question - yes, look at
> recursive, I missed that bit out -sorry. ian
>
> On Jan 22, 2:07 pm, grigri <[EMAIL PROTECTED]> wrote:
>
> > Model::find('list', ...) automatically assumes you want $recursive ->
> > -1 (no joins) unless you specify otherwise.
>
> > Try this:
>
> > $tags = $this->Output->Tag->find("list", array(
> >   "fields" => array(
> >     '{n}.Tag.id', // keyPath : Option value
> >     '{n}.Tag.name', // valuePath: Option display field
> >     '{n}.TagType.name' // groupPath : optgroups
> >   ),
> >   "order"=>array("TagType.name", "Tag.name ASC"),
> >   'recursive' => 0
> > ));
>
> > According to the code, the 'fields' argument can contain 1, 2 or 3
> > fields
>
> > 1 Field : Sets keyPath to default, uses the arg for the valuePath,
> > sets groupPath to null
> > 2 Fields : keyPath, valuePath specified (in order), groupPath is null
> > 3 Fields : In order: keyPath, valuePath, groupPath
>
> > On Jan 22, 1:47 pm, RichardAtHome <[EMAIL PROTECTED]> wrote:
>
> > > Thanks for replying ian, but I'm still getting the same result:
>
> > > Warning (512): SQL Error: 1109: Unknown table 'TagType' in order
> > > clause [CORE\cake\libs\model\datasources\dbo_source.php, line 440]
>
> > > And the SQL remains the same:
> > > Query: SELECT `Tag`.`id`, `Tag`.`name` FROM `tags` AS `Tag` WHERE 1 =
> > > 1 ORDER BY `TagType`.`name` ASC, `Tag`.`name` ASC
>
> > > As you can see, the TagTypes table is not being included so the order
> > > by fails.
>
> > > On Jan 22, 1:17 pm, ianh <[EMAIL PROTECTED]> wrote:
>
> > > > Try:
> > > > $tags = $this->Output->Tag->find
> > > > (
> > > >   "list",
> > > >   array
> > > >   (
> > > >     "order"=>array("TagType.name", "Tag.name ASC")
> > > >   )
> > > > );
>
> > > > The list method is now clever enough to insert a fields option that
> > > > includes your display key and primary key (usually something like name
> > > > and id respectively). If you want to generate a list that does not
> > > > include your models normal display key or primary key then there are
> > > > two ways to go; either:
>
> > > > 1. As in the threan pointed to by manish, retrieve all data with a
> > > > find then do Set::combine; or
> > > > 2. Just before you call your list method, set your models displayName
> > > > and/or primaryKey properties to whatever you want to have returned.
>
> > > > ianh
>
> > > > On Jan 22, 12:55 pm, manish <[EMAIL PROTECTED]> wrote:
>
> > > > >http://groups.google.com/group/cake-php/browse_thread/thread/996efa1f...
>
> > > > > On Jan 22, 4:20 pm, RichardAtHome <[EMAIL PROTECTED]> wrote:
>
> > > > > > Hi All
>
> > > > > > I've just upgraded a project to the latest beta 1.2 
> > > > > > (cake_1.2.0.6311-
> > > > > > beta) and am struggling to get my head around the new find("list")
> > > > > > syntax.
>
> > > > > > Previously, I had:
>
> > > > > > $tags = $this->Output->Tag->generateList(null, array("TagType.name",
> > > > > > "Tag.name ASC"), null, null, null, "{n}.TagType.name");
>
> > > > > > Which returned me values suitable for a mutliselect box split into
> > > > > > catagories (TagType.name)
>
> > > > > > I've updated this to use find("list"):
>
> > > > > > $tags = $this->Output->Tag->find("list",
> > > > > > array("order"=>array("TagType.name", "Tag.name ASC"), null, null,
> > > > > > null, "{n}.TagType.name"));
>
> > > > > > But this generates the following error:
> > > > > > SQL Error: 1109: Unknown table 'TagType' in order clause
>
> > > > > > The SQL being generated is:
>
> > > > > > Query: SELECT `Tag`.`id`, `Tag`.`name` FROM `tags` AS `Tag` WHERE 1 
> > > > > > =
> > > > > > 1 ORDER BY `TagType`.`name` ASC, `Tag`.`name` ASC
>
> > > > > > My question is: How to I get find("list") to return the data in the
> > > > > > same structure as my previous generateList() ?
>
> > > > > > Thanks in advance! :-)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to