<?php
/**
 * Created by PhpStorm.
 * 经纪人房源发布价格区间限制，房源属于某个区间日志类
 * User: 365
 * Date: 2017/7/1
 * Time: 12:23
 */
class house_publish_rule_log_model extends MY_Model
{
    /**
     * 板块表
     * @var string
     */
    private $tbl = 'house_publish_rule_log';

    /**
     * 类初始化
     */
    public function __construct()
    {
        parent::__construct(1,1,3);
    }

    /**
     * 获取某个区间类型，经纪人发布总量
     *
     */
    public function getBrokerHousePublishRuleTotal($uid,$type)
    {
        $startTime = mktime(0,0,0,date('m'),date('d'),date('Y'));
        $endTime = mktime(23,59,59,date('m'),date('d'),date('Y'));

        $this->dbback->where('uid', $uid);
        $this->dbback->where('type', $type);
        $this->dbback->where('addTime >=', $startTime);
        $this->dbback->where('addTime <=', $endTime);
        return $this->dbback->count_all_results($this->tbl);
    }

    /**
     * 添加数据
     *
     */
    public function add($data)
    {
        $result = 0;
        if ($this->db->insert($this->tbl, $data))
        {
            $result = $this->db->insert_id();
        }

        return $result;
    }

    /**
     * 获取单条数据
     *
     */
    public function getRow($houseId = 0,$houseType = 1,$type = 3,$uid = 0)
    {
        $this->dbback->select();

        if(!empty($houseId))
        {
            $this->dbback->where('houseId', $houseId);
        }

        $this->dbback->where('houseType', $houseType);

        if(!empty($type))
        {
            $this->dbback->where('type', $type);
        }

        if(!empty($uid))
        {
            $this->dbback->where('uid', $uid);
        }

        $startTime = mktime(0,0,0,date('m'),date('d'),date('Y'));
        $endTime = mktime(23,59,59,date('m'),date('d'),date('Y'));

        $this->dbback->where('addTime >=', $startTime);
        $this->dbback->where('addTime <=', $endTime);

        $result = array();
        $result = $this->dbback->get($this->tbl)->row_array();

        return $result;
    }

    /**
     * 删除单个数据
     *
     */
    public function delete($id)
    {
        $this->db->where_in('id', $id);
        $this->db->delete($this->tbl);
    }


}

/* End of file street_model.php */
/* Location: ./models/street_model.php */
