On Tue, Oct 11, 2011 at 6:15 AM, Angad Nadkarni
<[email protected]> wrote:
> Hi Matteo, this is not a bug. Cake requires the post_id field  to
> fetch the associated Post associated array
> as well, hence even when you don't mention it, the "PRIMARY" and
> "FOREIGN" key fields are always mentioned.

I agree with you when you saying that to fetch all the comments
associated to a given post the query engine need to work with
``post_id`` field, but what I quite don't understand is why such field
is not removed after such comments are fethced; is the $field
information used only before of the query? If so, are there any
particular reasons behind that choice?


Regards,
Matteo

> On Oct 10, 3:26 am, Matteo Landi <[email protected]> wrote:
>> Hi everybody,
>> I'm trying to create a simple cakephp application which handles posts
>> and comments (like the one presented in the tutorial); I have a Post
>> model which *hasMany* Comments, and I have a Comment which *belongsTo*
>> to a Post.
>>
>> I would like to use Post->hasMany['fields'] variable to reduce the set
>> of fetched attributes, but for some strange reasons, I'm getting also
>> attributes not present in the specified array; in particular, I get
>> all the specified attributes plus the foreignKey (e.g. if my Comment
>> is composed by an 'id', a 'body', a couple of date fields and
>> 'post_id' (our foreignKey), and if I set *fields* to array('id'), I
>> get back both 'id' and 'post_id' attributes).
>>
>> However, while I fetch the Post associated to a Comment, the list of
>> fetched attributes seems to match the one specified in the association
>> definition.
>>
>> Is this a bug, or is there anything I'm not taking into account?
>>
>> Regards,
>> Matteo
>>
>> --http://www.matteolandi.net/
>
> --
> 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
>



-- 
http://www.matteolandi.net/

-- 
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

Reply via email to