<?php
/**
 * 房源特色
 *
 * @author user
 */
class house_feature_test extends MY_Model {
    
    private $_tbl = 'house_feature_new';
    /**
     * 类初始化
     */
    public function __construct() 
    {
        parent::__construct();
    }
    
    public function find_feature($tbl, $infotypes)
    {
        $this->dbback->select('id,name');
        $this->dbback->where('tbl', $tbl);
        $this->dbback->like('infotypes', $infotypes);
        $feature = $this->dbback->get($this->_tbl)->result_array();
        $feature_arr = array();
		if(is_array($feature) && !empty($feature))
		{
			foreach($feature as $val)
			{
				$feature_arr[$val['id']] = $val['name'];
			}
		}
        return $feature_arr;
    }
    
    public function find_house_feature($feature, $tbl = 'sell')
    {
        $housefeatur = array();

        if($feature == '')
        {
            return $housefeatur;
        }
        $farr = explode("$", $feature);
        if(empty($farr) || !is_array($farr))
        {
            return $housefeatur;
        }
        else
        {
            $feature_arr = $this->find_feature($tbl, '');

            foreach($farr as $val)
            {
                $val = intval($val);
                if($val > 0 && $feature_arr[$val] != '')
                {
                    $housefeatur[$val] = $feature_arr[$val];
                }
            }
        }
        return $housefeatur;
    }
}
