<?php
if (!defined('BASEPATH'))
    exit('No direct script access allowed');
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of house_tag
 *
 * @author Administrator
 */
class house_tag_record_model extends MY_Model {
   

    /**
     * 表名
     * @var type 表名
     */
    private $table;

    public function __construct() {
        parent::__construct(1,1,1);
        $this->table = 'house_tag_record';
    }
    
    /**
     * 查找所有标签包
     * @param type $uid
     * @param type $startTime
     * @param type $endTime
     * @param type $start
     * @param type $number
     * @return type
     */
    public function findByAll() 
	{	
		$tag_info = $this->dbback->get($this->table)->result_array();
        return $tag_info;
    }

	/**
	 *插入标签包购买记录
	 *
	 *
	 *
	 */
		

	public function insertdata($id,$tag_num,$tag_name,$uid,$username,$truename,$telno,$master,$transaction_id,$time)
    {     
		
        $insert_data = array();
      
        $insert_data['tag_price_id']	= $id;
        $insert_data['tag_num']			= $tag_num;
        $insert_data['tag_name']		= $tag_name;
        $insert_data['uid']				= $uid;
        $insert_data['username']		= $username;

		$insert_data['truename']		= $truename;
		$insert_data['telno']			= $telno;
		$insert_data['master']			= $master;
        $insert_data['order_id']		= $transaction_id;
		$insert_data['date_add']		= $time;
		
	
        $this->db->insert($this->table,$insert_data);	
        
        return $this->db->insert_id();
    }



	public function findNumberBy($cond_where)
	{
		
		$this->dbback->where($cond_where);
        $count_num = $this->dbback->from($this->table)->count_all_results();
        
        return $count_num;
	
	}


	public function findBy($cond_where ,$order_key, $order_by, $limit, $offset)
	{
		
		$this->dbback->where($cond_where);
		//排序条件
        $this->dbback->order_by( $order_key , $order_by );

        //查询

        $arr_data = $this->dbback->get( $this->table , $limit , $offset )->result_array();
		
        return  $arr_data;
		
	}

	public function findPersonNum()
	{
		$mem_key ="find_persin_num";
		
		$cache = $this->mc->get($mem_key);        
		
        if(isset($cache['is_ok']) && $cache['is_ok'] == 1 )
        {
			
            $tag_info = $cache['data'];
        }
        else
        {	 
			
			$this->dbback->select('count(uid) as number');
			
			$tag_info = $this->dbback->get('house_tag_record')->result_array();

			$this->mc->add($mem_key , array('is_ok'=>1 , 'data'=>$tag_info) ,  600);
		}
		
        return $tag_info;


	
	}

    
}
?>