當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Subjects::save方法代碼示例

本文整理匯總了PHP中Subjects::save方法的典型用法代碼示例。如果您正苦於以下問題:PHP Subjects::save方法的具體用法?PHP Subjects::save怎麽用?PHP Subjects::save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Subjects的用法示例。


在下文中一共展示了Subjects::save方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Subjects();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Subjects'])) {
         $model->attributes = $_POST['Subjects'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->idSubjects));
         }
     }
     $this->render('create', array('model' => $model));
 }
開發者ID:upmunspel,項目名稱:abiturient,代碼行數:17,代碼來源:SubjectsController.php

示例2: actionCreate

 public function actionCreate()
 {
     $model = new Subjects('insert');
     $users_list = CHtml::listData(Users::model()->findAll(), 'id', 'username');
     if (Yii::app()->request->isPostRequest) {
         $classroom = Yii::app()->request->getParam('Subjects');
         $model->setAttributes($classroom);
         if (!Yii::app()->user->checkAccess('admin')) {
             $model->setAttribute('owner_id', Yii::app()->user->id);
         }
         if ($model->save()) {
             Yii::app()->user->setFlash('success', 'Предмет успешно создан');
             $this->redirect(['index']);
         }
     }
     $this->render('form', ['model' => $model, 'users_list' => $users_list]);
 }
開發者ID:sc0rp1d,項目名稱:studyschedule,代碼行數:17,代碼來源:SubjectsController.php

示例3: actionAdd

 public function actionAdd()
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     $request = \Yii::$app->request;
     $data = $request->post();
     if ($data['name'] == '') {
         return ['status' => 0, 'message' => 'Không được để trống tên'];
     }
     $data['created_at'] = time();
     $data['updated_at'] = time();
     try {
         $model = new Subjects();
         $model->attributes = $data;
         if ($model->save()) {
             return ['status' => 1, 'message' => 'Thành công'];
         }
         return ['status' => 0, 'message' => 'Có lỗi xảy ra'];
     } catch (Exception $ex) {
         return ['status' => 0, 'message' => 'Có lỗi xảy ra'];
     }
 }
開發者ID:huynt57,項目名稱:bluebee-ng,代碼行數:21,代碼來源:ProgramController.php

示例4: actionAddnew1

 public function actionAddnew1()
 {
     $model = new Subjects();
     // Ajax Validation enabled
     //$this->performAjaxValidation($model);
     // Flag to know if we will render the form or try to add
     // new jon.
     $flag = true;
     if (isset($_POST['Submit'])) {
         $flag = false;
         $model->attributes = $_POST['Subjects'];
         $model->save();
     }
     if ($flag) {
         Yii::app()->clientScript->scriptMap['jquery.js'] = false;
         $this->renderPartial('create1', array('model' => $model, 'id' => 2, 'batch_id' => $_GET['val1']), false, true);
     }
 }
開發者ID:SoftScape,項目名稱:open-school-CE,代碼行數:18,代碼來源:SubjectsController.php

示例5: actionAjax_Create

 public function actionAjax_Create()
 {
     if (isset($_POST['Subjects'])) {
         $model = new Subjects();
         //set the submitted values
         $model->attributes = $_POST['Subjects'];
         /*$data=SubjectName::model()->findByAttributes(array('id'=>$model->name));
         		if($data!=NULL)
         		{
         			$model->name=$data->name;
         			$model->code=$data->code;
         			
         		}*/
         //return the JSON result to provide feedback.
         if ($model->save(false)) {
             echo json_encode(array('success' => true, 'id' => $model->primaryKey));
             exit;
         } else {
             echo json_encode(array('success' => false));
             exit;
         }
     }
 }
開發者ID:SoftScape,項目名稱:open-school-CE,代碼行數:23,代碼來源:SubjectController.php

示例6: actionAjax_Create

 public function actionAjax_Create()
 {
     if (isset($_POST['ElectiveGroups'])) {
         $model = new ElectiveGroups();
         $subject = new Subjects();
         //set the submitted values
         $model->attributes = $_POST['ElectiveGroups'];
         //return the JSON result to provide feedback.
         if ($model->save(false)) {
             $subject->name = $model->name;
             $subject->code = $model->code;
             $subject->batch_id = $model->batch_id;
             $subject->no_exams = 0;
             $subject->max_weekly_classes = 3;
             $subject->elective_group_id = $model->id;
             $subject->is_deleted = 0;
             $subject->created_at = date('Y-m-d h:i:s');
             $subject->save();
             echo json_encode(array('success' => true, 'id' => $model->primaryKey));
             exit;
         } else {
             echo json_encode(array('success' => false));
             exit;
         }
     }
 }
開發者ID:akilraj1255,項目名稱:rajeshwari,代碼行數:26,代碼來源:ElectiveGroupsController.php

示例7: postAddSubjects

 public function postAddSubjects()
 {
     $validator = Validator::make(Input::all(), array('subject_name' => 'required|max:30|min:3', 'subject_code' => 'required|max:30|min:2'));
     if ($validator->fails()) {
         $response = array('status' => 'failed', 'msg' => 'Item is not updated', 'errors' => $validator, 'error_messages' => $validator->messages());
         return Response::json($response);
     } else {
         $subject_id = Input::get('subject_id');
         $subject_name = Input::get('subject_name');
         $subject_code = Input::get('subject_code');
         $class_id = Input::get('class_id');
         $section_id = Input::get('section_id');
         if ($subject_id) {
             $subjects = Subjects::find($subject_id);
             $subjects->subject_name = ucwords($subject_name);
             $subjects->subject_code = strtoupper($subject_code);
             if ($subjects->save()) {
                 $response = array('status' => 'success', 'msg' => 'Subjects created successfully', 'errors' => null, 'result' => array('subjects' => $subjects));
                 return Response::json($response);
             }
         } else {
             $subjects = new Subjects();
             $subjects->subject_name = ucwords($subject_name);
             $subjects->subject_code = strtoupper($subject_code);
             $subjects->class_id = $class_id;
             $subjects->section_id = $section_id;
             if ($subjects->save()) {
                 $response = array('status' => 'success', 'msg' => 'Setting created successfully', 'errors' => null, 'result' => array('subjects' => $subjects));
                 return Response::json($response);
             }
         }
     }
     $response = array('status' => 'failed', 'msg' => 'Item is not updated');
     return Response::json($response);
 }
開發者ID:vivekjaiswal90,項目名稱:schoolopedia,代碼行數:35,代碼來源:AdminTimeTableController.php


注:本文中的Subjects::save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。