Just as you can set 'foreignKey' or 'className' on the association array,
use 'fields':
var $hasMany = array(
array('Comment' => array(
'fields' => array('id', 'title')
))
);
In cake/libs/model/datasources/dbo_source.php, you can see that on line 879
for self joins (hasOne and belongsTo):
$self['fields'] = am($self['fields'], $this->fields($linkModel, $alias,
(isset($assocData['fields']) ? $assocData['fields'] : '')));
And line 1019 for hasMany:
'fields' => $this->fields($linkModel, $alias, $assocData['fields']),
-MI
---------------------------------------------------------------------------
Remember, smart coders answer ten questions for every question they ask.
So be smart, be cool, and share your knowledge.
BAKE ON!
blog: http://www.MarianoIglesias.com.ar
-----Mensaje original-----
De: [email protected] [mailto:[EMAIL PROTECTED] En nombre
de joel
Enviado el: Sábado, 07 de Abril de 2007 09:28 p.m.
Para: Cake PHP
Asunto: Limiting findAll() fields in associations
Let's say I have a Blog with many Comments, but I only want to return
some of the fields for the Blog and its Comments. Is it possible to
use findAll() to only return, for example, the fields Blog.id and
Blog.title (which I know how to do using the $fields parameter in
findAll), but also only Comment.id and Comment.title in all
associated, hasMany, Comments?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---