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


PHP Student::save方法代码示例

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


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

示例1: actionCreate

 /**
  * Creates a new Student model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $student = new Student();
     $user = new User();
     $person = new Person();
     if (Yii::$app->request->post()) {
         $params = Yii::$app->request->post();
         $person->load($params);
         $user->load($params);
         $user->password_hash = Yii::$app->getSecurity()->generatePasswordHash($params['User']['password_hash']);
         $student->load($params);
         if ($person->validate() && $user->validate() && $student->validate()) {
             $person->save(false);
             $user->person_id = $person->id;
             $user->register();
             $student->user_id = $user->id;
             $student->save();
             Yii::$app->session->setFlash('success', 'Se envío un correo de confirmación. Por favor verifique su correo electrónico');
             return $this->refresh();
         } else {
             Yii::$app->session->setFlash('danger', 'Ocurrió ff un error al guardar. Vuelve a intentar');
             return $this->refresh();
         }
     } else {
         return $this->render('create', ['student' => $student, 'user' => $user, 'person' => $person]);
     }
 }
开发者ID:RomarioLopezC,项目名称:RobotSS,代码行数:32,代码来源:DefaultController.php

示例2: saveStudenInfo

 public function saveStudenInfo()
 {
     if (!empty(Input::get('studId'))) {
         $studInfo = Student::find(Input::get('studId'));
     } else {
         $studInfo = new Student();
     }
     $studInfo['stud_num'] = Input::get('studNo');
     $studInfo['fname'] = Input::get('fname');
     $studInfo['lname'] = Input::get('lname');
     $studInfo['address'] = Input::get('address');
     $studInfo['zip'] = Input::get('zip');
     $studInfo['city'] = Input::get('drpCity');
     $studInfo['state'] = Input::get('drpState');
     $studInfo['phone'] = Input::get('pnumber');
     $studInfo['mobile'] = Input::get('mnumber');
     $studInfo['email'] = Input::get('email');
     $studInfo['year_lvl'] = Input::get('drpYearLvl');
     $studInfo['section'] = Input::get('drpSection');
     if ($studInfo->save()) {
         return 1;
     } else {
         return 2;
     }
 }
开发者ID:jhunel2389,项目名称:hp-sis,代码行数:25,代码来源:StudentController.php

示例3: actionCreate

 /**
  * Creates a new Student model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Student();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:oma378501,项目名称:attendance,代码行数:14,代码来源:StudentController.php

示例4: postThemmoi

 function postThemmoi(Request $request)
 {
     $model = new Student();
     $model->first_name = $request->txtfirst_name;
     $model->middle_name = $request->txtmiddle_name;
     $model->last_name = $request->txtlast_name;
     $model->address = $request->txtaddress;
     $model->identity = $request->txtidentity;
     $model->phone = $request->txtphone;
     $model->birthday = $request->txtbirthday;
     $model->save();
     $file = $request->file('txtimage');
     $file_name = $model['id'] . "-" . time() . "-" . $file->getClientOriginalName();
     $model->image = $file_name;
     $file->move('../resources/upload/hocsinh/', $file_name);
     $model->save();
     return redirect()->route('student');
 }
开发者ID:b0yblake1,项目名称:duan,代码行数:18,代码来源:StudentController.php

示例5: postStudentModal

 function postStudentModal(Request $request, Student $student)
 {
     $student->user->email = $request->get('email');
     $student->user->save();
     $student->programme = $request->get('programme');
     $student->active = $request->get('active');
     $student->group_id = $request->get('group_id') ?: null;
     $student->remark = $request->get('remark');
     $student->save();
 }
开发者ID:robindv,项目名称:WebDB,代码行数:10,代码来源:StaffController.php

示例6: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(StudentRequest $request)
 {
     $data = $request->all();
     $student = new Student();
     $student->fromArray($data);
     $student->save();
     flash()->success("ADDED");
     session(['attribute' => \Lang::get('general.STUDENT')]);
     return redirect($this->main_page);
 }
开发者ID:nstojanovickg,项目名称:diplomski,代码行数:15,代码来源:StudentController.php

示例7: actionCreate

 public function actionCreate()
 {
     $model = new Student();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $model->birthday = date('Y-m-d', strtotime($model->birthday));
         if ($model->save()) {
             return $this->redirect(Url::to(['/student/view', 'id' => $model->id]));
         }
     }
     return $this->render('create', ['model' => $model]);
 }
开发者ID:ustkirill,项目名称:testwork,代码行数:11,代码来源:StudentController.php

示例8: saveUser

 /**
  * @param $name
  * @param $email
  * @param $request
  * @param $workshop
  */
 private function saveUser($name, $email, $request, $workshop)
 {
     $user = new Student();
     if (!Student::isStudent($name, $email)) {
         $user->fill($request);
         $user->status = 'C';
         $user->profile = $this->getUserProfileString($request);
         $user->save();
     } else {
         $user = $user->getByEmailAndName($name, $email);
     }
     if (!$user->isRegistered($name, $email, $workshop->id)) {
         $user->workshops()->attach($workshop->id, ['sign_date' => date('Y-m-d H:i:s')]);
     }
 }
开发者ID:kevinslondon,项目名称:Yogaground,代码行数:21,代码来源:WorkshopListener.php

示例9: actionRegister

 public function actionRegister($co = null, $cl = null)
 {
     $model = new Student();
     if ($model->load(Yii::$app->request->post())) {
         $model->course_id = $co;
         $model->classid = $cl;
         $model->created_dt = date('Y-m-d H:i:s');
         $model->save();
         return $this->redirect(['success']);
         //return $this->redirect(['view', 'id' => $model->id]);
     } else {
         if (!empty($co)) {
             $courselist = Course::findOne($co);
         }
         return $this->render('register', ['model' => $model, 'courselist' => $courselist]);
     }
 }
开发者ID:kaweesak,项目名称:arit_training,代码行数:17,代码来源:StudentController.php

示例10: actionRegistration

 public function actionRegistration($role = '')
 {
     if (!\Yii::$app->user->isGuest) {
         $this->redirect(\Yii::$app->user->getReturnUrl());
     }
     if ($role == '') {
         return $this->render('registration');
     }
     $model = new User();
     $role_model = new Company();
     $model->role = User::ROLE_COMPANY;
     if ($role != 'company') {
         //Student registration
         $role = 'student';
         $role_model = new Student();
         $model->role = User::ROLE_STUDENT;
     }
     if ($model->load(Yii::$app->request->post()) && $role_model->load(Yii::$app->request->post()) && $model->register()) {
         if ($role == 'student') {
             $role_model->idUser = $model->id;
             if ($role_model->save()) {
                 return $this->render('registration_student_success', ['model' => $model]);
             }
         } else {
             $role_model->idUser = $model->id;
             //Upload logo
             if (isset($_FILES['Company']) && $_FILES['Company']['name']['logo_path'] != "") {
                 if (!in_array($_FILES['Company']['type']['logo_path'], $this->image_array)) {
                     $role_model->addError('logo_path', 'Доступные расширения для файла: jpg, gif, png.');
                 } else {
                     $rnd = rand(0, 9999);
                     $uploadedFile = UploadedFile::getInstance($role_model, 'logo_path');
                     $fileName = 'files/' . $rnd . '_' . $uploadedFile->name;
                     $role_model->logo_path = $fileName;
                     $uploadedFile->saveAs($fileName);
                 }
             }
             if ($role_model->save()) {
                 return $this->render('registration_company_success', ['model' => $model]);
             }
         }
     }
     return $this->render('registration_' . $role, ['model' => $model, 'role_model' => $role_model]);
 }
开发者ID:Sywooch,项目名称:RabotaNURE,代码行数:44,代码来源:SiteController.php

示例11: save

 public function save()
 {
     echo "SAVE function from studentController.php is working";
     $student = new Student();
     $studentName = Request::input('studentName');
     $email = Request::input('email');
     $studentRank = Request::input('studentRank');
     $studentPhone = Request::input('studentPhone');
     $img1 = Request::input('img1');
     $img2 = Request::input('img2');
     $img3 = Request::input('img3');
     $img4 = Request::input('img4');
     $img5 = Request::input('img5');
     print_r($studentName);
     $student->studentName = $studentName;
     $student->studentRank = $studentRank;
     $student->studentPhone = $studentPhone;
     $student->email = $email;
     $student->save();
     print_r($studentPhone);
     return redirect("/students");
 }
开发者ID:chris346,项目名称:laravel-project,代码行数:22,代码来源:StudentsController.php

示例12: addSubmit

 /**
  * When search form from add is submited
  *
  * @return Response
  */
 public function addSubmit($login)
 {
     // If the user is new, import some values from the API response.
     $json = EtuUTT::call('/api/public/users/' . $login)['data'];
     $student = Student::find($json['studentId']);
     if ($student === null) {
         $student = new Student(['student_id' => $json['studentId'], 'first_name' => $json['firstName'], 'last_name' => $json['lastName'], 'surname' => $json['surname'], 'email' => $json['email'], 'facebook' => $json['facebook'], 'branch' => $json['branch'], 'level' => $json['level'], 'ce' => 1, 'team_id' => EtuUTT::student()->team_id]);
         $student->save();
         // Error here a ignored, we just keep user without a picture if we cannot download it
         $picture = @file_get_contents('http://local-sig.utt.fr/Pub/trombi/individu/' . $json['studentId'] . '.jpg');
         @file_put_contents(public_path() . '/uploads/students-trombi/' . $json['studentId'] . '.jpg', $picture);
     } elseif ($student->team) {
         return $this->error('Cet étudiant fait déjà partie d\'une équipe. Il faut qu\'il la quitte avant de pouvoir être ajouté à une nouvelle équipe.');
     } else {
         $student->team_id = EtuUTT::student()->team_id;
         $student->ce = 1;
         $student->save();
     }
     $team = EtuUTT::student()->team;
     $team->validated = false;
     $team->save();
     return redirect(route('dashboard.ce.myteam'))->withSuccess($json['fullName'] . ' a bien été ajouté à votre équipe. Il faut maintenant qu\'il se connecte au site d\'intégration pour valider sa participation.');
 }
开发者ID:ungdev,项目名称:integration-UTT,代码行数:28,代码来源:CEController.php

示例13: actionCreate

 /**
  * Creates a new Student model.
  * If creation is successful, the browser will be redirected to the either
  * the index or the create page to add another.
  * @return mixed
  */
 public function actionCreate()
 {
     $transaction = Yii::$app->db->beginTransaction();
     // Get the user's school and the current date.
     $schoolId = Yii::$app->user->schoolId;
     $today = date('Y-m-d');
     $student = new Student();
     $student->contract_school_id = $schoolId;
     $student->start_date = $today;
     if ($student->load(Yii::$app->request->post()) && $student->save()) {
         // Affiliate the new student with the same school as the user
         $role = Role::find()->where(['like', 'name', 'student'])->one();
         $affiliation = new Affiliation();
         if ($affiliation->load(Yii::$app->request->post())) {
             $affiliation->student_id = $student->id;
             $affiliation->school_id = $schoolId;
             $affiliation->role_id = $role->id;
             $affiliation->date = $today;
             $affiliation->save();
         }
         /* Get the phone # that was posted along with the new student,
          * and assign it to the student via the newly-created ID.
          */
         $phone = new StudentPhone();
         if ($phone->load(Yii::$app->request->post())) {
             $phone->student_id = $student->id;
             $phone->save();
         }
         if ($affiliation->isSaved && $phone->isSaved) {
             $transaction->commit();
             $url = Html::a($student->name, ['update', 'id' => $student->id]);
             Yii::$app->session->setFlash('success', 'Student added: ' . $url);
             if (Yii::$app->request->post('then-add') !== null) {
                 return $this->redirect(['create']);
             } elseif (Yii::$app->request->post('then-edit') !== null) {
                 return $this->redirect(['update', 'id' => $student->id]);
             } else {
                 return $this->redirect(['index']);
             }
         } else {
             $transaction->rollBack();
             $msg = 'Unable to create student: ';
             //!!! find a better way to extract the model errors
             $msg .= serialize($affiliation->errors);
             $msg .= serialize($phone->errors);
             Yii::$app->session->setFlash('error', $msg);
         }
     }
     return $this->render('create', ['model' => $student]);
 }
开发者ID:NewPaltzKarateAcademy,项目名称:KIMS,代码行数:56,代码来源:StudentController.php

示例14: actionSignupstudent

 public function actionSignupstudent()
 {
     $name = $_POST['name'];
     $id = $_POST['id'];
     $email = $_POST['email'];
     $pass = $_POST['pass'];
     $model = new Student();
     $model->name = $name;
     $model->id = $id;
     $model->email = $email;
     $model->password = $pass;
     $status = array();
     if ($model->save()) {
         $status["status"] = "ok";
         $status["name"] = $name;
         $status["email"] = $email;
         $status["id"] = $id;
     } else {
         $status["status"] = "failed";
     }
     return json_encode($status);
 }
开发者ID:amal-khaled,项目名称:Find-Me-Application,代码行数:22,代码来源:StudentController.php

示例15: doSave

 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      ConnectionInterface $con
  * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws PropelException
  * @see save()
  */
 protected function doSave(ConnectionInterface $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their corresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aProfessor !== null) {
             if ($this->aProfessor->isModified() || $this->aProfessor->isNew()) {
                 $affectedRows += $this->aProfessor->save($con);
             }
             $this->setProfessor($this->aProfessor);
         }
         if ($this->aStudent !== null) {
             if ($this->aStudent->isModified() || $this->aStudent->isNew()) {
                 $affectedRows += $this->aStudent->save($con);
             }
             $this->setStudent($this->aStudent);
         }
         if ($this->aTranslationLanguage !== null) {
             if ($this->aTranslationLanguage->isModified() || $this->aTranslationLanguage->isNew()) {
                 $affectedRows += $this->aTranslationLanguage->save($con);
             }
             $this->setTranslationLanguage($this->aTranslationLanguage);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
                 $affectedRows += 1;
             } else {
                 $affectedRows += $this->doUpdate($con);
             }
             $this->resetModified();
         }
         if ($this->adminUserCredentialsScheduledForDeletion !== null) {
             if (!$this->adminUserCredentialsScheduledForDeletion->isEmpty()) {
                 \App\Models\AdminUserCredentialQuery::create()->filterByPrimaryKeys($this->adminUserCredentialsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->adminUserCredentialsScheduledForDeletion = null;
             }
         }
         if ($this->collAdminUserCredentials !== null) {
             foreach ($this->collAdminUserCredentials as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
开发者ID:nstojanovickg,项目名称:diplomski,代码行数:66,代码来源:AdminUser.php


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