protected $fields=array('id','parentid','name','is_show');
protected $_auto=array(
array('is_hot','value',0),
array('is_new','value',0),
array('is_best','value',0),
array('addtime','function','time')
);
//自動過濾 public function _facade($option=array()){
$data=array();
foreach ($option as $key=>$value){
if (in_array($key, $this->fields)) {
$data[$key]=$value;
}
}
return $data;
}
//自動填充
public function _autoFill($data){
foreach($this->_auto as $value){
if (!array_key_exists($value[0], $data)) {
switch ($value[1]){
case 'value':
$data[$value[0]]=$value[2];
break;
case 'function':
$data[$value[0]]=call_user_func($value[2]);
break;
}
}
}
return $data;
}