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


PHP Time::save方法代码示例

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


在下文中一共展示了Time::save方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 Time();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Time'])) {
         $model->attributes = $_POST['Time'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:dieos2,项目名称:bolao,代码行数:17,代码来源:TimeController.php

示例2: dirname

<?php

require_once dirname(__FILE__) . "/_ajaxSetup.php";
$user = LoginManager::enforceLogin();
$data = json_decode($_POST['data']);
if (!isset($data->player) || !isset($data->time) || !isset($data->penalties)) {
    PageContent::ajaxError("missing parameters");
}
$player = Player::get($data->player->pid);
if (!$player) {
    PageContent::ajaxError("No pid found for player {$data->player->name}");
}
$time = new Time($player, $data->time, $data->penalties);
if (!$time->save()) {
    PageContent::ajaxError("error while saving");
}
PageContent::ajax();
开发者ID:nmonterroso,项目名称:speedpoolTimer,代码行数:17,代码来源:savePlayerTime.php

示例3: actionTimes

 public function actionTimes($id)
 {
     // извлекаем элементы, которые будем обновлять в пакетном режиме,
     // предполагая, что каждый элемент является экземпляром класса модели 'Item'
     $items = Time::model()->findAll('quest_id = :quest_id', array(':quest_id' => $id));
     if (isset($_POST['Time'])) {
         $valid = true;
         foreach ($items as $i => $item) {
             if (isset($_POST['Time'][$i])) {
                 $item->attributes = $_POST['Time'][$i];
             }
             $valid = $item->validate() && $valid;
             if ($valid) {
                 if ($item->save()) {
                     Yii::app()->user->setFlash('status', 'Изменения сохранены');
                 }
             }
         }
     }
     $model = new Time();
     if (isset($_POST['add'])) {
         $model->time1 = $_POST['Time']['time1'];
         $model->time2 = $_POST['Time']['time2'];
         $model->price = $_POST['Time']['price'];
         $model->quest_id = $id;
         if ($model->save()) {
             $this->refresh();
         }
     }
     // отображаем представление с формой для ввода табличных данных
     $this->render('times', array('items' => $items, 'model' => $model));
 }
开发者ID:R-thomas,项目名称:quest,代码行数:32,代码来源:QuestsController.php

示例4: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'show' page.
  */
 public function actionCreate()
 {
     $model = new Time($this->action->id);
     if (isset($_POST['Time'])) {
         // collect user input data
         $model->attributes = $_POST['Time'];
         if (!isset($_POST['Time']['managerId'])) {
             // set manager based on the task
             if ($model->taskId >= 1) {
                 $criteria = new CDbCriteria();
                 $criteria->order = "`t`.`userPriority` ASC, `t`.`id` ASC";
                 if (($user2Task = User2Task::model()->findByAttributes(array('taskId' => $model->taskId, 'role' => User2Task::MANAGER), $criteria)) !== null) {
                     $model->managerId = $user2Task->userId;
                 } else {
                     $model->managerId = 0;
                 }
             } else {
                 $model->managerId = 0;
             }
         }
         if (!isset($_POST['Time']['consultantId'])) {
             // set consultant based on the task
             if ($model->taskId >= 1) {
                 $criteria = new CDbCriteria();
                 $criteria->order = "`t`.`userPriority` ASC, `t`.`id` ASC";
                 if (($user2Task = User2Task::model()->findByAttributes(array('taskId' => $model->taskId, 'role' => User2Task::CONSULTANT), $criteria)) !== null) {
                     $model->consultantId = $user2Task->userId;
                 } else {
                     $model->consultantId = 0;
                 }
             } else {
                 $model->consultantId = 0;
             }
         }
         // validate with the current action as scenario and save without validation
         if (($validated = $model->validate()) !== false && ($saved = $model->save(false)) !== false) {
             // set success message
             MUserFlash::setTopSuccess(Yii::t('hint', 'The new "{title}" time record has been successfully created.', array('{title}' => MHtml::wrapInTag($model->title, 'strong'))));
             // go to the 'show' page
             $this->redirect(array('show', 'id' => $model->id));
         }
     } else {
         // pre-assigned attributes (default values for a new record)
         if (Yii::app()->user->checkAccess(User::MANAGER) || Yii::app()->user->checkAccess(User::ADMINISTRATOR)) {
             $model->isConfirmed = Time::IS_CONFIRMED;
         }
         if (isset($_GET['taskId'])) {
             // task is known
             $model->taskId = $_GET['taskId'];
         }
     }
     $this->render($this->action->id, array('model' => $model));
 }
开发者ID:megabr,项目名称:web3cms,代码行数:57,代码来源:TimeController.php

示例5: actionIndex

 /**
  * Migrate from old project management system.
  */
 public function actionIndex()
 {
     // check rights
     if (!Yii::app()->user->checkAccess(User::ADMINISTRATOR)) {
         throw new CHttpException(403, Yii::t('Yii', 'You are not authorized to perform this action.'));
     }
     // models to migrate
     $migrate = array('User' => false, 'Company' => false, 'CompanyPayment' => false, 'Project' => false, 'Task' => false, 'Time' => true, 'Invoice' => false, 'Expense' => false);
     // start
     $message = '';
     // we won't migrate unless form is submitted
     if (Yii::app()->request->isPostRequest) {
         // default criteria
         $findAllCriteria = new CDbCriteria();
         $findAllCriteria->order = "`id` ASC";
         if ($migrate['User']) {
             // user
             $mUsers = MUser::model()->findAll($findAllCriteria);
             if (is_array($mUsers)) {
                 $i = $j = $c = 0;
                 $accessType = array('customer' => 'client', 'consultant' => 'consultant', 'manager' => 'manager', 'admin' => 'administrator');
                 $accessLevel = array('customer' => 2, 'consultant' => 3, 'manager' => 4, 'admin' => 5);
                 foreach ($mUsers as $oldModel) {
                     if (($model = User::model()->findByPk($oldModel->id)) !== null) {
                         $model->delete();
                     }
                     // old model validation
                     if (User::model()->findByAttributes(array('email' => $oldModel->email))) {
                         $oldModel->email = rand(10, 99) . $oldModel->email;
                     }
                     $closeTime = strtotime($oldModel->close_date);
                     $isActive = empty($oldModel->close_date) || $oldModel->close_date === '0000-00-00' || $closeTime === false;
                     // new model
                     $model = new User('migrate');
                     $model->username = $oldModel->email;
                     $model->password = md5($oldModel->password);
                     $model->email = $oldModel->email;
                     $model->screenName = $oldModel->name;
                     $model->accessType = isset($accessType[$oldModel->class]) ? $accessType[$oldModel->class] : 'member';
                     $model->accessLevel = isset($accessLevel[$oldModel->class]) ? $accessLevel[$oldModel->class] : 1;
                     $model->isActive = $isActive ? '1' : '0';
                     $model->createTime = strtotime($oldModel->last);
                     $model->id = $oldModel->id;
                     if ($model->save()) {
                         $i++;
                         if (($userDetails = UserDetails::model()->findByPk($model->id)) !== null) {
                             $userDetails->delete();
                         }
                         $userDetails = new UserDetails('migrate');
                         $userDetails->emailConfirmationKey = md5(uniqid(rand(), true));
                         $userDetails->initials = $oldModel->inits;
                         $userDetails->occupation = $oldModel->title;
                         $userDetails->deactivationTime = $isActive ? null : $closeTime;
                         $userDetails->administratorNote = '[from migration]';
                         $userDetails->userId = $model->id;
                         $userDetails->save();
                         // relation between user and company
                         if ($oldModel->customer_id >= 1) {
                             $user2Company = new User2Company('migrate');
                             $user2Company->userId = $model->id;
                             $user2Company->companyId = $oldModel->customer_id;
                             $user2Company->position = 'owner';
                             //$oldModel->title
                             if ($user2Company->save()) {
                                 $c++;
                             }
                         }
                     }
                     $j++;
                 }
                 $message .= $i . ' of ' . $j . ' users' . ($i === $c ? '' : ' with ' . $c . ' company (relations)') . ' have been migrated.<br/>';
             }
         }
         if ($migrate['Company']) {
             // company
             $mCustomers = MCustomer::model()->findAll($findAllCriteria);
             if (is_array($mCustomers)) {
                 $i = $j = $l = 0;
                 foreach ($mCustomers as $oldModel) {
                     if (($model = Company::model()->findByPk($oldModel->id)) !== null) {
                         $model->delete();
                     }
                     $closeTime = strtotime($oldModel->close_date);
                     $isActive = empty($oldModel->close_date) || $oldModel->close_date === '0000-00-00' || $closeTime === false;
                     $model = new Company('migrate');
                     $model->title = $oldModel->name;
                     $model->titleAbbr = $oldModel->inits;
                     $model->contactName = $oldModel->contact;
                     $model->contactEmail = $oldModel->contact_email;
                     $model->content = '[from migration]';
                     $model->contentMarkup = 'text';
                     $model->invoiceDueDay = $oldModel->terms_days;
                     $model->isActive = $isActive ? '1' : '0';
                     $model->deactivationTime = $isActive ? null : $closeTime;
                     $model->createTime = strtotime($oldModel->last);
                     $model->id = $oldModel->id;
                     if ($model->save()) {
//.........这里部分代码省略.........
开发者ID:megabr,项目名称:web3cms,代码行数:101,代码来源:MigrateController.php


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