<?php
namespace DAO\Goods;
/**
 * 运费扩展
 * User: liuyuzhen
 * Date: 2018/6/28
 * Time: 19:29
 * Description:
 */

class TransportExtendModel extends \DAO\AbstractModel{
    /**
     * 表名
     *
     * @var string
     */
    protected $_tableName = 'han_transport_extend';

    /**
     * 主键
     *
     * @var string
     */
    protected $_primaryKey = 'id';

    public function init()
    {

    }

    public function  find($where,$field = \Our\NameConst::allField){
        $this->setDb($this->dbName);
        $result = $this->db->select($field)->from($this->_tableName)->where($where)->fetchOne();
        return $result;
    }

    public function getList($where=array(),$field = \Our\NameConst::allField,$order = array('is_default'=>'asc')){
        $this->setDb($this->dbName);
        $this->db->select($field)->from($this->_tableName)->where($where);
        if($order){
            foreach($order as $key=>$value){
                $this->db->order($key,$value);
            }
        }
        $result = $this->db->fetchAll();
        return $result;
    }


    private static $_instance = null;

    /**
     * 获取类实例
     */
    public static function getInstance($dbName = \Our\DbNameConst::salveDBConnectName) {
        if (!(self::$_instance instanceof self)) {
            self::$_instance = new self($dbName);
        }
        return self::$_instance;
    }
}