Specify fields in a recursive find with cakephp

Posted by Razor Storm on Stack Overflow See other posts from Stack Overflow or by Razor Storm
Published on 2011-01-05T03:50:25Z Indexed on 2011/01/05 3:53 UTC
Read the original article Hit count: 164

Filed under:
|
|
|

Suppose I have a table Recipe that hasmany ingredients.

I do a recursive find to grab recipes with their associated ingredients:

$this->Recipe->find('all', array('fields' => array('id','title','description')));

Here I can use the 'fields' attribute to specify that I only want it to return id, title, and description. However, despite this, cakephp still returns ALL columns from the ingredients table.

How do I tell cakephp that I only want ingredient table's id and name fields?

btw ingredient model is "Ingredient" and the table is ingredients, and the aggregation table is recipes_ingredients.

© Stack Overflow or respective owner

Related posts about sql

Related posts about mysql