Chapter 4 Exercise to make comment

1 message Options
Embed this post
Permalink
shin

Chapter 4 Exercise to make comment

Reply Threaded More More options
Print post
Permalink
At the end of chapter 4 there is an exercise. It says "building a “has many” relationship for the posts and comments tables on your own"

I created the following and it seems working. But I just want to know if I am doing right.
Thanks in advance.

-----------------------------

comments_controller.php

<?php
class Comment extends AppModel {
var $name = 'Comment';
var $belongsTo = array(
'Post'=>array(
'className'=>'Post',
'foreignKey'=>'post_id',
'conditions'=>null,
'fields'=>null
)
);
}
?>



comment.php

<?php
class Comment extends AppModel {
var $name = 'Comment';
var $belongsTo = array(
'Post'=>array(
'className'=>'Post',
'foreignKey'=>'post_id',
'conditions'=>null,
'fields'=>null
)
);
}
?>