使用 CakePHP 1.3,我开发了带有帖子和评论表的博客引擎,最近我注意到在数据库中,尽管 Comment 模型已经定义了正确的验证,但我在内容列中有空值的记录:
<?php
class Comment extends AppModel {
var $name = 'Comment';
var $sequence = 'comments_seq';
var $belongsTo = array(
'Post' => array(
'className' => 'Post',
'foreignKey' => 'post_id'
)
);
var $validate = array(
'content' => array(
'required' => array (
'rule' => 'notEmpty',
'message' => 'Content can't be empty.'
)
),
'post_id' => array(
'rule' => 'notEmpty'
),
'created' => array(
'rule' => 'notEmpty'
)
);
?>
CakePHP 框架中是否存在错误或上面定义的验证不正确或不充分?