<?php
class attributeModel extends model{
	public $base;
	public function __construct(&$base){
		parent::__construct($base);
		$this->base=$base;
		$this->table="attribute";
	}
	
	
	
	public function attr_type(){
		return array(
			1=>"唯一属性",
			2=>'单选属性',
			3=>"多选属性",
		);
	}
	
	public function input_type(){
		return array(
			1=>"手动输入",
			2=>"列表选择",
		);
	}
	
	public function getAttr($cat_id=0){
		$cat_id=intval($cat_id);
		$option=array(
			"where"=>" cat_id=".$cat_id." ",
			"order"=>" orderindex ASC"
		);
		$data=$this->select($option);
		if($data){
			foreach($data as $k=>$v){
				$c=$v['content'];
				if($v['input_type']==2){
					$d=explode("\n",str_replace("\r\n","\n",$c));
					$select=array();
					foreach($d as $vv){
						$s=explode("=",$vv);
						$select[$s[0]]=$s[1];
					}
					$v['select']=$select;
				}
				$data[$k]=$v;
			}
		}
		return $data;
	}
}

?>