Try it like this:

$params = array(
  // ...
  'fields' => array('State.id', 'State.name', 'State.id')
  // ...
);

$result = array_values($this->State->find('list', $params));

On Aug 19, 6:32 pm, Josoroma <[EMAIL PROTECTED]> wrote:
> With the following piece of code:
>
>         function getJsonStates() {
>
>                 //Configure::write("debug",0);
>
>                 $params = array(
>                                                 'conditions'    => null,
>                                                 'fields'                => 
> array(
>                                                                               
>                   'State.id',
>                                                                               
>                   'State.name'
>                                                                               
>           ),
>                                                 'recursive'     => 0
>                 );
>
>                 $states = $this->State->find('all', $params);
>
>                 $this->set(compact('states'));
>
>         }
>
> Im generating a javascript object like this:
>
> [{"State":{"id":"1","name":"Lizenburgue"}},{"State":
> {"id":"2","name":"Oak"}},{"State":{"id":"3","name":"San Pedro"}}]
>
> Using list instead of all: $this->State->find('list', $params);
>
> Im generating a javascript object like this:
>
> [{"1":"Lizenburgue","2":"Oak","3":"San Pedro"}]
>
> ***But i need to generate the result as:
>
> [{"1":"Lizenburgue"},{"2":"Oak"},{"3":"San Pedro"}]
>
> There exist some way of doing that using find with extract or combine?
>
> Any help is welcome, 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 [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