<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * zsb
 *
 * 业务类库
 *
 * @package         zsb
 * @author          EllisLab Dev Team
 * @copyright       Copyright (c) 2006 - 2014, HOUSE365, Inc.
 * @link            http://nj.sell.house.com
 * @since           Version 1.0
 * @filesource
 */

// ------------------------------------------------------------------------

/**
 * 板块类
 *
 * 板块类文件功能描述
 *
 * @package         zsb
 * @subpackage      Models
 * @category        Models
 * @author          fisher
 */
class Street_base_model extends MY_Model 
{ 
    /**
     * 板块表
     * @var string 
     */
    private $_street_tbl = 'street';
    
    /**
     * 查询字段
     * @var string 
     */
    public $select_fields = '';
    
    /**
     * 设置需要查询的字段
     * @param array $select_fields
     */
    public function set_select_fields($select_fields)
    {
        $select_fields_str = '';
        if(isset( $select_fields ) && !empty($select_fields))
        {   
            $select_fields_str = implode( ',', $select_fields) ;
        }
        $this->select_fields = $select_fields;
    }
    
    /**
     * 获取需要查询的字段
     * @return string
     */
    public function get_select_fields()
    {
        return $this->select_fields;
    }
    
    /**
     * 类初始化
     */
    public function __construct()
    {
        parent::__construct(1,1,3);
    }
    
    /**
     * 根据板块编号获取详细记录
     * @param int $id 板块编号
     * @return array 返回一条板块的记录
     */
    public function find_by_id($id)
    {
        //查询字段
        if ($this->get_select_fields())
        {
            $this->dbback->select($this->get_select_fields());
        }
        //查询条件
        $this->dbback->where('id', $id);
        return $this->dbback->get($this->_street_tbl)->row_array();
    }
    
    /**
     * 根据条件查询板块记录
     * @param string $where 查询条件
     * @return array 满足条件的板块数组
     */
    public function find_by($where = '')
    {
        //查询字段
        if ($this->get_select_fields())
        {
            $this->dbback->select($this->get_select_fields());
        }
        //查询条件
        $this->dbback->where($where);
        return $this->dbback->get($this->_street_tbl)->result_array();
    }
    
    /**
     * 获取区属下板块列表详细记录
     * @param string $district 区属
     * @return array 板块列表
     */
    public function find_by_district($district)
    {
        //查询字段
        if ($this->get_select_fields())
        {
            $this->dbback->select($this->get_select_fields());
        }
        $this->dbback->where('district', $district);
        return $this->dbback->get($this->_street_tbl)->result_array();
    }
}

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