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
)
);
}
?>