I have this model:
public function getPeopleByName($name){
> $this->unbindModel(array('hasMany' => array('OfficePersonTask')));
>
> $options['fields'] = array("Person.id", "Person.full_name");
> $options['conditions'] = array("UPPER(CONCAT(Person.last_name, ' ',
> Person.first_name)) LIKE UPPER('".$name."%')");
>
> return $this->find('all', $options);
> }
and related controller:
public function getPeopleByName(){
> $people = $this->Person->getPeopleByName($_GET['name']);
> $this->set(array(
> 'People' => $people,
> '_serialize' => array('People')
> ));
> }
this get me the following json:
{
> "People": [
> {
> "Person": {
> "id": "1",
> "full_name": "Ringo Star"
> }
> },
> {
> "Person": {
> "id": "2",
> "full_name": "Jim Morrison"
> }
> }
> ]
> }
This is correct but I would remove the Person subgroup. So, every id and
full_name should be member of People group. How can I do that?
--
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
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php