A Comment can be related to any other model.
For example Event 123 could have a comment which would look like this:
INSERT INTO comments ('class','foreign_id','name','body') VALUES
('Event',123,'title','comment body');
Or Post 456 may have a comment which would look like this:
INSERT INTO comments ('class','foreign_id','name','body') VALUES
('Post',456,'another title','another comment body');
When you define the foreign_id in the Post or Event model, this is
used for finding data, not for saving data.
In order to save the comment to the right record you need to define a
Comment.class and Comment.foreign_id.
Hope this helps to explain it.
On Jan 13, 10:51 am, kicaj <[email protected]> wrote:
> Hi
>
> I use this
> example:http://mrphp.com.au/code/code-category/cakephp/cakephp-1-2/attach-com...
>
> And I i have a question:
> In models (Post, Event) we set property 'foreignKey' = 'foreign_id' in
> $hasMany,
> so why we must set again in 'view' action in 'Posts' controller:
> $this->data['Comment']['foreign_id'] = $id;,
>
> why this value is not added automatic?
>
> Anybody konw?
> Any solutions?
>
> Sorry, but my english is not perfect:)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---