Tuesday, July 31, 2012

Choose what field show when depth level is 2

In CakePHP 2.1 I have prepared a Json webservice. This is an excerpt of what I get:

    {
       Offices:[
          {
             Office:{
                id:"1",
                Company:{
                   id:"1",
                   name:"ABC Software"
                }
             },
             Person:{
                mail:"sASa@sAAsS.it",
                OfficePersonTask:[
                   {
                      office_id:"1",
                      person_id:"1",
                      task_id:"1"
                   }
                ]
             }
          }
       ]
    } 

What I want is the possibility to show only some field from relative database, so the method that query the database have `$options['fields']` properly setting, so if I want to show person's mail I write:

$options['fields'] = array("Person.mail");

but what if I want to show company's id or company's name whice is one level deeper?

--
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
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: