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


PHP ActiveRecord::isAttributeChanged方法代码示例

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


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

示例1: isAttributeChanged

 public function isAttributeChanged($name)
 {
     if ($name == 'picUrl') {
         return $this->_old_picUrl != $this->picUrl;
     }
     return parent::isAttributeChanged($name);
 }
开发者ID:noikiy,项目名称:wowewe,代码行数:7,代码来源:MWxAction.php

示例2: isAttributeChanged

 /**
  * @param string $name
  * @param bool $identical
  *
  * @return bool
  */
 public function isAttributeChanged($name, $identical = true)
 {
     if (in_array($name, $this->getMultiLangFields())) {
         $language = \Yii::$app->language;
         $name = $this->buildMultilangFieldName($name, $language);
     }
     return parent::isAttributeChanged($name, $identical);
 }
开发者ID:pbabilas,项目名称:bcode,代码行数:14,代码来源:AbstractMultiLangModel.php

示例3: searchQuery

 /**
  * @param ActiveRecord $model
  * @param array $opts
  * @return ActiveQuery | array
  */
 static function searchQuery($model, $opts = [])
 {
     $opts = ArrayHelper::merge(['data' => null, 'query' => null, 'columns' => [], 'filters' => []], $opts);
     $columns = $opts['columns'];
     $filters = $opts['filters'];
     $data = $opts['data'];
     if (null === $data) {
         $data = \Yii::$app->request->get();
     }
     $query = $opts['query'];
     if (is_string($query)) {
         $query = call_user_func([$model, $opts['query']]);
     } elseif (null === $query) {
         $query = $model->find();
         foreach (array_filter($model->getAttributes()) as $prop => $val) {
             $query->andWhere([$prop => $val]);
         }
     }
     if ($model->load($data) && $model->validate()) {
         foreach ($model->getAttributes($model->safeAttributes()) as $name => $value) {
             if ($model->isAttributeChanged($name)) {
                 $attributeTypes = [];
                 if (method_exists($model, 'attributeTypes')) {
                     $attributeTypes = $model->attributeTypes();
                 }
                 $type = null;
                 if (isset($attributeTypes[$name])) {
                     $type = $attributeTypes[$name];
                 }
                 // Default filter function
                 $filterFunc = isset($filters[$name]) && is_callable($filters[$name]) ? $filters[$name] : function (ActiveQuery $query, $name, $value, $type) {
                     /**
                      * @var string $name
                      * @var string|array $value
                      * @var string $type
                      */
                     $query->andFilterWhere(static::searchAttribute($name, $value, $type));
                 };
                 if (isset($columns[$name])) {
                     $name = $columns[$name];
                 }
                 call_user_func($filterFunc, $query, $name, $value, $type);
             }
         }
     }
     return $query;
 }
开发者ID:goodizer,项目名称:yii2-helpers,代码行数:52,代码来源:GridSearchHelper.php

示例4: beforeUpdate

 /**
  * Метод срабатывает в момент обновления существующей записи моедли.
  */
 public function beforeUpdate()
 {
     if (in_array($this->owner->scenario, $this->scenarios)) {
         foreach ($this->attributes as $attribute) {
             if ($this->owner->isAttributeChanged($attribute)) {
                 $fileTempPath = $this->getTempPath($attribute);
                 if (is_file($fileTempPath)) {
                     rename($fileTempPath, $this->getPath($attribute));
                     if ($this->deleteOnSave === true and $this->owner->getOldAttribute($attribute)) {
                         $this->delete($attribute, true);
                     }
                     $this->triggerEventAfterUpload();
                 } else {
                     $this->owner->setAttribute($attribute, $this->owner->getOldAttribute($attribute));
                 }
             }
         }
     }
     // Удаляем указаные атрибуты и их файлы если это нужно
     if (!empty($this->deleteScenarios) and in_array($this->owner->scenario, $this->deleteScenarios)) {
         foreach ($this->deleteScenarios as $attribute => $scenario) {
             if ($this->owner->scenario === $scenario) {
                 $file = $this->getPath($attribute);
                 if (is_file($file) and unlink($file)) {
                     $this->owner->{$attribute} = null;
                 }
             }
         }
     }
 }
开发者ID:lembadm,项目名称:yii2-fileapi-behavior,代码行数:33,代码来源:UploadBehavior.php


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