<?php
/**
 * 表模型 user 
 * @copyright reginx.com
 * @Created By Reginx tab tool
 */
class user_tab extends tab {
    
    /**
     * 字段过滤规则
     *
     * @var unknown_type
     */
    public $filter = array(
        'uname'     =>    array('filter' , 'text'),
        'passwd'    =>    array('filter' , 'text'),
        'nick'      =>    array('filter' , 'text'),
        'openid'    =>    array('filter' , 'text'),
        'sex'       =>    'intval',
        'adate'     =>    'intval',
        'lastlogin' =>    'intval',
        'lastplay'  =>    'intval',
    );

    /**
     * 默认值
     *
     * @var unknown_type
     */
    public $default = array(
        'sex'       => 0,
        'adate'     => REQUEST_TIME,
        'lastlogin' => REQUEST_TIME,
        'lastplay'  => 0
    );

    /**
     * 验证规则
     *
     * @var unknown_type
     */
    public $validate = array(
        array(
            'key'   => 'uname',
            'type'  => 0,
            'rule'  => 'email',
            'msg'   => '请输入邮箱帐号!'
        ),
        array(
            'key'   => 'passwd',
            'type'  => 0,
            'rule'  => 'require',
            'msg'   => '请输入密码'
        )
    );
    
    /**
     * 检测唯一性
     *
     * @return unknown
     */
    public function chkuniq(){
        return !$this->initdata()->where("uname = '{$this->data['uname']}' and id != {$this->data['id']}")->count();
    }
    
}
?>