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


PHP Worker::save方法代碼示例

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


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

示例1: actionAddWorker

 function actionAddWorker()
 {
     $model = new Worker();
     $user = new User();
     $u_transaction = $user->dbConnection->beginTransaction();
     $this->performAjaxValidation($user);
     if (isset($_POST['Worker'])) {
         if (isset($_POST['User'])) {
             $user->login = $_POST['User']['login'];
             $user->password = $_POST['User']['password'];
             $user->role = 'worker';
             if ($user->save()) {
                 $model->attributes = $_POST['Worker'];
                 $model->user_id = $user->id;
                 $timestamp = CDateTimeParser::parse($model->birthdate, 'dd-MM-yyyy');
                 $model->birthdate = date('Y-m-d', $timestamp);
                 if ($model->save()) {
                     $u_transaction->commit();
                     $this->redirect(array('view', 'id' => $model->user_id));
                 } else {
                     $u_transaction->rollback();
                     //откатываем данные по юзеру, в случае если данные по работнику не сохранились
                     throw new CHttpException(901, 'Ошибка сохранения данных работника.');
                 }
             } else {
                 throw new CHttpException(902, "Ошибка сохранения данных авторизации");
             }
         } else {
             throw new CHttpException(903, 'Ошибка передачи данных авторизации.');
         }
     } else {
         $this->render('add_worker', array('model' => $model, 'user' => $user));
     }
 }
開發者ID:vnilov,項目名稱:delivery,代碼行數:34,代碼來源:MainController.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 Worker();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Worker'])) {
         $model->attributes = $_POST['Worker'];
         if ($model->save()) {
             $this->redirect(array('admin'));
         }
     }
     $this->render('create', array('model' => $model));
 }
開發者ID:FranHurtado,項目名稱:traza,代碼行數:17,代碼來源:WorkerController.php


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