我一直在尝试在模型和数据库中定义数据库关系和约束?目前它正在抛出错误。我有两个表“帖子”和“评论”。我在我的模型中定义了如下关系:
class Comment extends AppModel {
public $belongsTo = array(
'Post' => array(
'className' => 'Post',
'foreignKey' => 'post_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
}
和
class Post extends AppModel {
public $hasMany = array(
'Comment' => array(
'className' => 'Comment',
'foreignKey' => 'post_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
)
);
}
我错过了什么吗?任何人请帮忙。
提前致谢..