当前位置: 首页>>代码示例>>PHP>>正文


PHP Board::save方法代码示例

本文整理汇总了PHP中Board::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Board::save方法的具体用法?PHP Board::save怎么用?PHP Board::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Board的用法示例。


在下文中一共展示了Board::save方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     //Validation
     $rules = array('name' => 'required', 'message' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to('/community/boards/create')->withInput()->withErrors($validator);
     }
     $board = new Board();
     $board->name = Input::get('name');
     $board->save();
     $message = new Message();
     $message->body = Input::get('message');
     $message->board_id = $board->id;
     $message->user_id = Auth::user()->id;
     $message->save();
     return Redirect::to('/community/boards/' . $board->id)->with('flash_message', 'Your board has been successfully created!')->with('alert_class', 'alert-success');
 }
开发者ID:woofiewilly,项目名称:seed,代码行数:23,代码来源:BoardController.php

示例2: actionCreate

	/**
	 * Creates a new model.
	 * If creation is successful, the browser will be redirected to the 'view' page.
	 */
	public function actionCreate()
	{
		$model=new Board;

		// Uncomment the following line if AJAX validation is needed
		// $this->performAjaxValidation($model);

		if(isset($_POST['Board']))
		{
			$model->attributes=$_POST['Board'];
			if($model->save())
				$this->redirect(array('view','id'=>$model->id));
		}

		$this->render('create',array(
			'model'=>$model,
		));
	}
开发者ID:nucleartux,项目名称:YiiCh,代码行数:22,代码来源:BoardController.php

示例3: post_new

 /**
  * Create a board
  */
 public function post_new()
 {
     $data = Input::get();
     $rules = array('name' => 'required', 'description' => 'required', 'position' => 'integer');
     $val = Validator::make($data, $rules);
     if ($val->fails()) {
         Session::flash('status', 'new-board-fail');
         return Redirect::to('/')->with_input()->with_errors($val);
     } else {
         if (!isset($data['position'])) {
             $data['position'] = 1;
         }
         // make the board
         $board = new Board();
         $board->name = $data['name'];
         $board->description = $data['description'];
         $board->position = $data['position'];
         $board->save();
         return Redirect::to('/');
     }
 }
开发者ID:nickfun,项目名称:funbb,代码行数:24,代码来源:board.php

示例4: StaffPermission

            if ($BOARD['required_permission_id'] != null) {
                $permission = new StaffPermission($db);
                $permission = $permission->findOneByStaffPermissionId($BOARD['required_permission_id']);
                if ($permission == null) {
                    $ERRORS[] = 'Invalid permission specified.';
                } else {
                    $permission_id = $permission->getStaffPermissionId();
                }
            }
            // end perm specified; check it
            if (sizeof($ERRORS) > 0) {
                draw_errors($ERRORS);
            } else {
                $board->setBoardName($BOARD['name']);
                $board->setBoardDescr($BOARD['description']);
                $board->setBoardLocked($BOARD['locked']);
                $board->setNewsSource($BOARD['news_source']);
                $board->setOrderBy($BOARD['order_by']);
                $board->setRequiredPermissionId($permission_id);
                $board->setBoardCategoryId($category->getBoardCategoryId());
                $board->save();
                $_SESSION['board_notice'] = "You have saved <strong>{$board->getBoardName()}</strong>.";
                redirect('admin-boards');
            }
            // end no errors
            break;
            // end save
    }
    // end state switch
}
// end no errors
开发者ID:OwlManAtt,项目名称:imageforum-ys,代码行数:31,代码来源:edit.php

示例5: postAsk

 public function postAsk()
 {
     try {
         if (!isset($_POST)) {
             throw new \Exception('Request error!');
         }
         $keys = array('name', 'sex', 'email', 'ask', 'content', 'code', 'isPrivate', 'user_id');
         $values = array();
         $bool = true;
         foreach ($keys as $key) {
             $values[$key] = \Arr::get($_POST, $key, false);
             if ($values[$key] === false) {
                 $bool = false;
             }
         }
         if (!$bool) {
             throw new \Exception('Request error!');
         }
         if (!\Captcha::getInstance()->valid($values['code'])) {
             throw new \Exception('驗証碼錯誤');
         }
         $values['isPrivate'] = $values['isPrivate'] == 'n' ? '0' : '1';
         $b = new \Board();
         $b->name = $values['name'];
         $b->gender = $values['sex'];
         $b->email = $values['email'];
         $b->topic = $values['ask'];
         $b->content = $values['content'];
         $b->isPrivate = $values['isPrivate'];
         $b->user_id = empty($values['user_id']) ? '' : (int) $values['user_id'];
         $b->save();
         return \Response::json(array('status' => 'ok'));
     } catch (\Exception $e) {
         return \Response::json(array('status' => 'error', 'message' => $e->getMessage()));
     }
 }
开发者ID:kettanyam,项目名称:20141001done,代码行数:36,代码来源:BoardController.php


注:本文中的Board::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。