Пример #1
0
 /**
  * 单元 编辑后更新数据库
  */
 function update()
 {
     $section = new SectionModel();
     if (!!($data = $section->create())) {
         if (!empty($data['id'])) {
             if (false !== $section->save()) {
                 //同时更新menu_item里面的标题
                 $menu_item = M('MenuItem');
                 $title = $data['title'];
                 $new_data = array('title' => $title);
                 $new_where = array('type_id' => array('eq', $data['id']), 'type' => 'Section');
                 $bools = $menu_item->where($new_where)->save($new_data);
                 if ($bools) {
                     $this->assign('jumpUrl', __URL__ . '/index');
                     $this->success('更新成功');
                 }
             } else {
                 $this->error('更新失败:' . $section->getDbError());
             }
         } else {
             $this->error('请选择编辑用户');
         }
     } else {
         $this->error('更新失败:( ' . $section->getError() . ' )');
     }
 }