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


PHP Model::beforeSave方法代码示例

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


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

示例1: beforeSave

 /**
  * @author thientd
  */
 public function beforeSave($options = array())
 {
     $result = parent::beforeSave($options);
     if ($result) {
         $exists = $this->exists();
         $dateFields = array('modifier');
         if (!$exists) {
             $dateFields[] = 'creator';
         }
         $fields = array();
         if (isset($this->data[$this->alias])) {
             $fields = array_keys($this->data[$this->alias]);
         }
         $username = $this->__getLoginName();
         foreach ($dateFields as $updateCol) {
             if (in_array($updateCol, $fields) || !$this->hasField($updateCol)) {
                 continue;
             }
             if (!empty($this->whitelist)) {
                 $this->whitelist[] = $updateCol;
             }
             $this->set($updateCol, $username);
         }
     }
     return $result;
 }
开发者ID:sonnt1991,项目名称:Goikenban,代码行数:29,代码来源:AppModel.php

示例2: beforeSave

 public function beforeSave()
 {
     parent::beforeSave();
     App::import('Controller', 'App');
     $appController = new AppController();
     ///===> String To Slug
     /// A variável transformUrl deve ser colocada na Model
     if (!empty($this->transformUrl)) {
         foreach ($this->transformUrl as $key => $value) {
             //echo $key ." => ". $value ."<br>";
             $url_amigavel = $appController->stringToSlug($this->data[$this->alias][$value]);
             $this->data[$this->alias][$key] = $url_amigavel;
         }
     }
     ///===> Salvando Imagens, caso existam
     if (!empty($this->type_files)) {
         foreach ($this->type_files as $key => $value) {
             //echo $campo ." => ". $parametros ."<br>";
             if (!empty($this->data[$this->alias][$key . '_nome_imagem'])) {
                 $this->data[$this->alias][$key] = $this->data[$this->alias][$key . '_nome_imagem'];
                 $this->data[$this->alias][$key . '_th_hidden'] = $appController->thumbPath($this->data[$this->alias][$key . '_nome_imagem']);
             }
         }
     }
     return true;
 }
开发者ID:indirasam,项目名称:aquitemmata,代码行数:26,代码来源:AppModel.php

示例3: beforeSave

 /**
  * standard beforeSave() callback
  * Save string IPs as longs
  *
  * @param array $options
  * @return true
  */
 public function beforeSave($options = array())
 {
     foreach ($this->fieldsToLong as $field) {
         if (isset($this->data[$this->alias][$field]) && !is_numeric($this->data[$this->alias][$field])) {
             $this->data[$this->alias][$field] = ip2long($this->data[$this->alias][$field]);
         }
     }
     return parent::beforeSave($options);
 }
开发者ID:stonelasley,项目名称:seo,代码行数:16,代码来源:SeoAppModel.php

示例4: beforeSave

 public function beforeSave($options = array())
 {
     parent::beforeSave($options);
     $formatted = $this->formatDateFields($this->data, $this->datesToSave, "%Y-%m-%d");
     if (isset($formatted[0])) {
         $this->data[$this->alias] = array_replace($this->data[$this->alias], $formatted[0][$this->alias]);
     }
     $this->data = Sanitize::clean($this->data);
     return true;
 }
开发者ID:AmmonMa,项目名称:cake_ERP,代码行数:10,代码来源:AppModel.php

示例5: beforeSave

 public function beforeSave()
 {
     /*if ($this->isNewRecord) {
     			//do nothing
     		}
     	   	else {
     			$this->update_time = new CDbExpression('NOW()');
     		}*/
     $this->update_time = new CDbExpression('NOW()');
     return parent::beforeSave();
 }
开发者ID:scottsdesigns,项目名称:example-php-challenge,代码行数:11,代码来源:UserProfile.php

示例6: beforeSave

 public function beforeSave($options = array())
 {
     if (!empty($_SESSION['ProxyAuth']['realUser'])) {
         //check if user is proxied for logging purposes
         //need to log....
         $proxyUser = $_SESSION['Auth']['User'];
         $realUser = $_SESSION['ProxyAuth']['realUser'];
         $logString = json_encode(array('proxyUser' => $proxyUser, 'realUser' => $realUser, 'accessedPage' => $this->name, 'requestData' => $this->data));
         $this->log($logString, 'proxy');
     }
     return parent::beforeSave($options);
 }
开发者ID:byu-oit-appdev,项目名称:student-ratings,代码行数:12,代码来源:AppModel.php

示例7: beforeSave

 public function beforeSave($options = array())
 {
     parent::beforeSave($options);
     $schema = $this->schema();
     $class = get_class($this);
     if (isset($this->data[$class])) {
         $this->data[$class] = $this->addTimeToData($this->data[$class]);
     }
     if (isset($this->data[$class])) {
         $this->data[$class] = $this->addLoggedUserToData($this->data[$class]);
     }
 }
开发者ID:pdkhuong,项目名称:BBG,代码行数:12,代码来源:AppModel.php

示例8: beforeSave

 public function beforeSave($options = array())
 {
     $parent = parent::beforeSave($options);
     if (empty($this->data[$this->alias]['name'])) {
         return $parent;
     }
     $name = $this->data[$this->alias]['name'];
     $name_slug = strtolower(Inflector::slug($name));
     $name_variable = Inflector::variable($name_slug);
     $this->data[$this->alias] += compact('name_variable', 'name_slug');
     return $parent;
 }
开发者ID:JacopKane,项目名称:Cake-Nod,代码行数:12,代码来源:NodAppModel.php

示例9: beforeSave

 /**
  * beforeSave
  *
  * @return	boolean
  * @access	public
  */
 public function beforeSave($options = array())
 {
     $result = parent::beforeSave($options);
     // 日付フィールドが空の場合、nullを保存する
     foreach ($this->_schema as $key => $field) {
         if (('date' == $field['type'] || 'datetime' == $field['type'] || 'time' == $field['type']) && isset($this->data[$this->name][$key])) {
             if ($this->data[$this->name][$key] == '') {
                 $this->data[$this->name][$key] = null;
             }
         }
     }
     return $result;
 }
开发者ID:kenz,项目名称:basercms,代码行数:19,代码来源:BcAppModel.php

示例10: beforeSave

 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->create_time = new CDbExpression('NOW()');
         $this->update_time = new CDbExpression('NOW()');
         $this->create_by = Yii::app()->user->id;
         $this->update_by = Yii::app()->user->id;
     } else {
         $this->update_time = new CDbExpression('NOW()');
         $this->update_by = Yii::app()->user->id;
     }
     return parent::beforeSave();
 }
开发者ID:scottsdesigns,项目名称:example-php-challenge,代码行数:13,代码来源:UserRoles.php

示例11: beforeSave

 protected function beforeSave()
 {
     $passwordDiffers = true;
     /**
      * If existing user, check password
      */
     if (!$this->getIsNewRecord()) {
         if (isset($this->oldAttributes['password']) && strcmp($this->oldAttributes['password'], $this->password) == 0) {
             $passwordDiffers = false;
         }
     }
     if ($passwordDiffers && !empty($this->password)) {
         $this->password = $this->hashPassword($this->password);
     } elseif (!empty($this->oldAttributes['password'])) {
         $this->password = $this->oldAttributes['password'];
     }
     return parent::beforeSave();
 }
开发者ID:santhoshanand,项目名称:cranium-crm,代码行数:18,代码来源:User.php

示例12: beforeSave

 /**
  * beforeSave if a file is found, upload it, and then save the filename according to the settings
  *
  */
 function beforeSave(Model $Model, $options = array())
 {
     if (isset($Model->data[$Model->alias][$this->options[$Model->alias]['fileVar']])) {
         $file = $Model->data[$Model->alias][$this->options[$Model->alias]['fileVar']];
         $this->Uploader[$Model->alias]->file = $file;
         if ($this->Uploader[$Model->alias]->hasUpload()) {
             $fileName = $this->Uploader[$Model->alias]->processFile();
             if ($fileName) {
                 $Model->data[$Model->alias][$this->options[$Model->alias]['fields']['name']] = $fileName;
                 $Model->data[$Model->alias][$this->options[$Model->alias]['fields']['size']] = $file['size'];
                 $Model->data[$Model->alias][$this->options[$Model->alias]['fields']['type']] = $file['type'];
             } else {
                 return false;
                 // we couldn't save the file, return false
             }
             unset($Model->data[$Model->alias][$this->options[$Model->alias]['fileVar']]);
         } else {
             unset($Model->data[$Model->alias]);
         }
     }
     return $Model->beforeSave();
 }
开发者ID:beckye67,项目名称:Icing,代码行数:26,代码来源:FileUploadBehavior.php

示例13: beforeSave

 /**
  * Выполняет действия перед сохранением записи
  */
 public function beforeSave()
 {
     parent::beforeSave();
 }
开发者ID:atanych,项目名称:todo,代码行数:7,代码来源:Task.php

示例14: beforeSave

 function beforeSave($options = array())
 {
     parent::beforeSave($options);
     return true;
 }
开发者ID:shashin62,项目名称:abc_audit,代码行数:5,代码来源:app_model.php

示例15: beforeSave

 /**
  * @brief Called before each save operation, after validation. Return a non-true result
  * to halt the save.
  *
  * @link http://api13.cakephp.org/class/model#method-ModelbeforeSave
  *
  * @param $created True if this save created a new record
  * @access public
  *
  * @return boolean True if the operation should continue, false if it should abort
  */
 public function beforeSave($options = array())
 {
     return parent::beforeSave($options);
 }
开发者ID:nani8124,项目名称:infinitas,代码行数:15,代码来源:AppModel.php


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