|
In CakePHP 2.1 I have prepared a Json webservice. This is an excerpt of what I get: { 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 [hidden email] For more options, visit this group at http://groups.google.com/group/cake-php |
|
You can use Containable behavior and write something like this:
$Office->find('all', array( ... 'contain' => array(//or 'contains' -> check manual ;) 'Company' => array('fields' => array('name')), 'Person' => array( 'fields' => array('mail'), 'OfficePersonTask' => array( ) 'Office' => array('fields' => 'name'), 'Task' => array('fields' => 'name'), ), ), ... )); Or try setting the fields names in $hasMany, $hasOne, etc array http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html#hasone On Tuesday, July 31, 2012 12:16:38 PM UTC+2, Mariano C. wrote: -- 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 [hidden email] For more options, visit this group at http://groups.google.com/group/cake-php |
|
In reply to this post by Mariano C.
It is working, but how can I make a sort of conditional where? For example, I get a json like this
{ This Json is prepared by the following model method: public function getOfficesByRegion($region){ If I want to remove all the info about a "Bad person" what can I do? If I remove comment from conditions row all that I get is: {
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 [hidden email] For more options, visit this group at http://groups.google.com/group/cake-php |
| Powered by Nabble | Edit this page |
