Hey there, what I would usually do in your situation is structure the
comments table like this:
id
body
created
modified
user_id
model
unique_id
When a user posts a comment about a video, the model field would be
Video and the unique_id would be the id of the video.
You could then declare your relationship as such
Video.php
<?php
var $hasMany => array(
'Comment' => array(
'className' => 'Comment',
'foreignKey' => 'unique_id',
'conditions' => 'Comment.model = "Video"',
'order' => 'Comment.created DESC'
)
);
?>
Help?
On Nov 11, 7: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
-~----------~----~----~----~------~----~------~--~---