<?php

Doo::loadCore('db/DooModel');

class UsersVoucher extends DooModel {

    public $id;
    public $vid;
    public $userid;
    public $vmoney;
    public $addtime;
    public $vname;
    public $_table = 'zh_users_voucher';
    public $_primarykey = 'id';
    public $_fields = array('id', 'vid', 'userid', 'vmoney', 'addtime', 'vname');

    public function __construct() {
        parent::setupModel(__CLASS__);
    }

    public function checkuser($userid,$vid){
        $result = $this->getOne(array('where' => 'userid='.$userid.' and vid='.$vid, 'asArray' => TRUE));
        if(!empty($result)){
            return false;
        }else{
            return true;
        }
    }

    public function getvoucher($userid,$limit){
        return $this->find(array('where' => 'userid='.$userid, 'desc' => 'id', 'limit' => $limit, 'asArray' => TRUE));
    }

}

?>