<?php

namespace DAO;
/**
 * User: liuyuzhen
 * Date: 2018/8/29
 * Time: 15:01
 * Description:
 */
class FrontLogModel extends \DAO\AbstractModel {


    private $logField = 'content as logContent , gmt_create as logTime';
    /**
     * 表名
     *
     * @var string
     */
    protected $_tableName = 'han_front_log';

    /**
     * 主键
     *
     * @var string
     */
    protected $_primaryKey = 'id';
    public function init(){

    }

    public function insert($param){
        $param['gmt_create'] =TIMESTAMP;
        $this->setDb(\Our\DbNameConst::masterDBConnectName);
        return $this->db->insert($this->_tableName)->rows($param)->execute();
    }

    public function getList($where){
        $this->setDb($this->dbName);
        if(is_array($where)){
            $where=$this->db->getSqlWhereByArray($where);
        }
        $result = $this->db->select($this->logField)->from($this->_tableName)->where($where)->fetchAll();
        return $result;
    }


    /**
     * 类实例
     *
     * @var \DAO\UserModel
     */
    private static $_instance = null;

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

        return self::$_instance;
    }

}
