コード例 #1
0
 /**
  *保存
  */
 function save()
 {
     $Attribute = new AutoattributeModel();
     $data['attr_value'] = I('post.child');
     $data['attr_name'] = $Attribute->getAttrName('science', $data['attr_value']);
     $data['sc_title'] = I('post.sc_title');
     $data['sc_content'] = I('post.sc_content');
     $data['update_time'] = $this->getCurrentTime();
     $action = I('post.HDaction');
     $Science = M('Science');
     if ($action == 'create') {
         $data['create_time'] = $this->getCurrentTime();
         $result = $Science->add($data);
         if ($result > 0) {
             $this->success('保存成功', U('Science/index'));
         } else {
             $this->error('保存失败');
         }
     } elseif ($action == 'edit') {
         $id = I('post.HDid');
         //              $this->success($id);
         $result = $Science->where('id=' . $id)->save($data);
         if ($result > 0) {
             $this->success('更新成功', U('Science/index'));
         } else {
             $this->error('更新失败');
         }
     }
 }
コード例 #2
0
 /**
  *
  * 保存新闻信息
  */
 function save()
 {
     $action = I('post.HDaction');
     $Notice = D('Notice');
     $AutoAttr = new AutoattributeModel();
     $id = I('post.HDid');
     $data['notice_title'] = I('post.notice_title');
     $data['notice_type'] = I('post.notice_type');
     $data['notice_discript'] = I('post.notice_descript');
     $data['notice_content'] = I('post.notice_content');
     $data['notice_type_name'] = $AutoAttr->getAttrName('notice', $data['notice_type']);
     if ('create' == $action) {
         $data['creator'] = UID;
         $data['create_time'] = $this->getCurrentTime();
         $data['update_time'] = $this->getCurrentTime();
         $vail = $Notice->create($data);
         if ($vail) {
             $id = $Notice->add();
             if ($id > 0) {
                 $this->success('创建成功', U('Notice/index'));
             }
         } else {
             $this->error($Notice->getError());
         }
     } elseif ('edit' == $action) {
         $data['update_time'] = $this->getCurrentTime();
         $vail = $Notice->create($data);
         if ($vail) {
             $result = $Notice->where('id=' . $id . '')->save($data);
             if ($result > 0) {
                 $this->success('更新成功!', U('Notice/index'));
             }
         } else {
             $this->error($Notice->getError());
         }
     }
 }