/** * 所有的 属性-属性值 hashList * return array( * attr_id=> array( * attr_name => attr_name-data, * vals => array( * key => data * ) * ),... * ) */ public function hashList() { $return = array(); $attr_M = new AttrModel(); $attrs = $attr_M->where(AttrModel::$ablemap)->order('sort asc,id desc')->select(); foreach ($attrs as $atrow) { $return[$atrow['id']] = $atrow; $tmpmap = array('attr_id' => $atrow['id']); $tmpmap = array_merge(self::$ablemap, $tmpmap); $return[$atrow['id']]['vals'] = $this->where($tmpmap)->order('sort asc,id desc')->select(); } return $return; }
public function update($id) { $id = (int) $id; if ($id <= 0) { $this->error('请选择要更新的属性'); } $model = new AttrModel(); $data = I('post.'); if (false === $model->create($data, Model::MODEL_UPDATE)) { $this->error($model->getError()); } if (false === $model->where('`id`=' . $id)->save()) { $this->error($model->getError()); } $this->success('更新成功', cookie(C('CURRENT_URL_NAME'))); }