<?php

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

class Voucher extends DooModel {

    public $id;
    public $vanme;
    public $vcode;
    public $vcost;
    public $vcount;
    public $vstarttime;
    public $vendtime;
    public $vaddtime;
    public $status;
    public $_table = 'zh_voucher';
    public $_primarykey = 'id';
    public $_fields = array('id', 'vname', 'vcode', 'vcost', 'vcount', 'vstarttime', 'vendtime', 'vaddtime', 'status');

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

    public function getAll($sql = '', $limit){
        if(!empty($sql)){
            return $this->find(array('where' => $sql, 'desc' => 'id', 'limit' => $limit, 'asArray' => TRUE));
        }else{
            return $this->find(array('desc' => 'id', 'limit' => $limit, 'asArray' => TRUE));
        }
    }

    public function getRowbyCode($code){
        return $this->getOne(array('where' => 'vcode="'.$code.'"', 'asArray' => TRUE));
    }
}

?>