当前位置: 首页>>代码示例>>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;未经允许,请勿转载。