后台和前台模型虽然命名不同,但数据定义是一致的。
我们先来看一个默认的数据模型定义:
这是一个名为 guestbook的前台数据模型
class model_guestbook extends model
 {
             function __construct()
             {
                         parent::__construct();
  
                         $this->_table = $this->db->options['prefix'].'guestbook';
                         $this->_primary = 'gid';
                         $this->_fields = array('gid','typeid', 'title', 'content', 'userid', 'username', 'gender', 'email','qq','msn','telephone','address','homepage','isview','ip','addtime','reply','replyer','replytime');
                         $this->_readonly = array('gid');
                         $this->_create_autofill = array('userid'=>$this->_userid, 'username'=>$this->_username, 'addtime'=>TIME, 'ip'=>IP);
                         $this->_update_autofill = array();
                         $this->_filters_input = array();
                         $this->_filters_output = array();
                         $this->_validators = array(
                                    'title'=>array(
                                                'not_empty'=>array('留言标题不能为空'),
                                                'max_length'=>array(100, '留言标题不能超过100个字符'),
                                    )
                         );
             }
 }
下面具体介绍每一项的定义规范。