Esempio n. 1
0
 public function insert()
 {
     $model = new AttrModel();
     if (false === $model->create($_POST, Model::MODEL_INSERT)) {
         $this->error($model->getError());
     }
     if (false === $model->add()) {
         $this->error($model->getError());
     }
     $this->success('新建成功', U(CONTROLLER_NAME . '/lists'));
 }
Esempio n. 2
0
 /**
  * 所有的 属性-属性值 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;
 }