Hey Teknoid, I haven't used the polymorphic behavior before, but it looks like a similar approach to what I had posted, obviously better. I think my solution works well on a basic level but if you then wanted to see all the comments for a particular video (in this case) you would have to manually unbind and then rebind the comments model with new conditions.
Am I right in assuming that? On Nov 11, 9:25 am, teknoid <[EMAIL PROTECTED]> wrote: > Strange, my previous post didn't post, but just in case here it is > again: > > Sounds like you need polymorphic > behavior:http://bakery.cakephp.org/articles/view/polymorphic-behavior > > On Nov 11, 10:37 am, ThierryDD <[EMAIL PROTECTED]> wrote: > > > Currently, I define my BelongsTo relations as: > > > var $belongsTo = array( > > 'User' => array( > > 'className' => 'User', > > 'foreignKey' => 'user_id' > > ), > > 'Post' => array( > > 'className' => 'Post', > > 'foreignKey' => 'post_id' > > ), > > 'Photo' => array( > > 'className' => 'Photo', > > 'foreignKey' => 'photo_id' > > ), > > 'Video' => array( > > 'className' => 'Video', > > 'foreignKey' => 'video_id' > > ) > > ); > > > And then I use an additional 'type' field in my database that I will > > set to either 'post', 'photo' or 'video'. > > > Would you have a better idea? > > > Cheers, > > > Thierry --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
