Your associations will be something like: Activity belongsTo User hasMany Comment
>From Comment model, one can do: $this->User->Activity->save(...) So, this could be done in afterSave() of a behavior for Comment. The behavior should work fine for any model that is associated with User. You should use Cake's naming conventions: users, activities, comments, etc. for tables, and user.php, activity.php, comment.php for the models. On Tue, Apr 21, 2009 at 6:03 AM, gaurav.v.sharma <gaurav.v.sha...@gmail.com> wrote: > > But i won't be able to give additional information to afterSave() > method in model. ($data.....? that I want to insert.) > > If i am adding a comment to a topic, then I want to record it in > activities table which I think will not be possible by afterSave() > method because it will be in context to only the model in which it is > defined in. and how is it possible to modify one model table from > another model class (tbl_activities (activities.php) from tbl_comments > (comments.php). :-( > > > > On Apr 20, 9:46 pm, brian <bally.z...@gmail.com> wrote: >> Maybe the easiest solution would be to create a Behavior that your >> Comment, Item, etc. models implement. An afterSave() method would then >> update the acitivities table. >> >> On Mon, Apr 20, 2009 at 8:46 AM, gaurav.v.sharma >> >> <gaurav.v.sha...@gmail.com> wrote: >> >> > hi all, >> >> > If we want to save all the related model data then we use the saveAll >> > () method. But what should be done if I want to make an entry in that >> > table which is not directly related to the related table. >> >> > I have created a table named tbl_acitivites in which I am recording >> > the actions of users like(added, deleted, commented) etc. etc. in this >> > table I am updating the values of user_id and topic_id along with the >> > action done. >> >> > My problem is that whenever a user posts a comments related to a >> > topic/ or reports the topic or adds an item to topiv then the >> > tbl_activities should also be updated with required information. But >> > it seems that I am stuck over here as to how do I update the table >> > tbl_activities whenever an action (commented, reported, added) is >> > performed because there is no direct relationship between the >> > tbl_activities and tbl_comments, tbl_reported, tbl_items. >> >> > I hope I am able to illustrate my problem clearly. >> >> > Help me out please. >> >> > thanks > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---