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


PHP ActiveRecord::load方法代码示例

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


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

示例1: load

 public function load($data)
 {
     if (isset($data[self::getAdditionForm()])) {
         $this->additionFieldsForm = $data[self::getAdditionForm()];
     }
     return parent::load($data);
 }
开发者ID:vfrbgt,项目名称:test-task-yii2,代码行数:7,代码来源:Tour.php

示例2: load

 /**
  * @param array $data
  * @param null $formName
  * @return bool
  */
 public function load($data, $formName = null)
 {
     $this->trigger(self::EVENT_BEFORE_LOAD);
     $result = parent::load($data, $formName);
     $this->trigger(self::EVENT_AFTER_LOAD);
     return $result;
 }
开发者ID:NullRefExcep,项目名称:yii2-core,代码行数:12,代码来源:Model.php

示例3: load

 public function load($data, $formName = null)
 {
     foreach ($data as $name => $value) {
         $this->tryToSetRelation($name, $value);
     }
     return parent::load($data, $formName);
 }
开发者ID:yinheark,项目名称:yincart2,代码行数:7,代码来源:ActiveRecord.php

示例4: load

 /**
  * @inheritdoc
  */
 public function load($data, $formName = null)
 {
     $data = GxModelHelper::adaptToMassiveAssignment($data, static::className());
     if (false === $formName) {
         $formName = '';
     }
     return parent::load($data, $formName);
 }
开发者ID:dlds,项目名称:yii2-giixer,代码行数:11,代码来源:GxActiveRecord.php

示例5: load

 public function load($data, $formName = null)
 {
     if ($this->widgetModel !== null) {
         $this->widgetModel->load($data, $formName);
         return parent::load($data, $formName);
     } else {
         return parent::load($data, $formName);
     }
 }
开发者ID:worstinme,项目名称:yii2-widgets,代码行数:9,代码来源:Widgets.php

示例6: load

 public function load($data, $formName = null)
 {
     if (parent::load($data, $formName)) {
         if ($this->scenario == self::SCENARIO_FILE_UPLOAD) {
             if (!$this->fileUpload instanceof UploadedFile) {
                 $this->fileUpload = UploadedFile::getInstance($this, 'fileUpload');
             }
         }
         return true;
     } else {
         return false;
     }
 }
开发者ID:omnilight,项目名称:yii2-models,代码行数:13,代码来源:File.php

示例7: load

 /**
  * inherite load() function
  */
 public function load($data, $formName = null)
 {
     parent::load($data, $formName);
     if ($this->attributes['time_point']) {
         $dateTime = \DateTime::createFromFormat("Y-m-d?H:i:s?", $this->attributes['time_point']);
         $this->setAttributes(['time_point' => $dateTime->format('Y-m-d H:i:s')]);
     }
     if (null == $this->attributes['primary_pollutant']) {
         $this->setAttributes(['primary_pollutant' => '']);
     }
     if (null == $this->attributes['quality']) {
         $this->setAttributes(['quality' => '']);
     }
 }
开发者ID:Olwn,项目名称:pm25,代码行数:17,代码来源:AirQuality.php

示例8: loadWithTranslations

 /**
  * Load owner model and translation models from data.
  * @param $data
  * @param null $languages array of languages for loading
  * @param null $formName
  * @param null $translationFormName
  * @return bool
  */
 public function loadWithTranslations($data, $languages, $formName = null, $translationFormName = null)
 {
     if ($this->owner->load($data, $formName)) {
         if (!$languages) {
             throw new InvalidParamException('Languages must be set.');
         }
         foreach ($languages as $language) {
             $modelI18n = static::getTranslation($language);
             $modelI18n->load($data, $translationFormName);
         }
         return true;
     }
     return false;
 }
开发者ID:maddoger,项目名称:yii2-core,代码行数:22,代码来源:TranslatableBehavior.php

示例9: load

 public function load($data, $formName = null)
 {
     $loaded = parent::load($data, $formName);
     if (!$this->date) {
         $this->date = date('Y-m-d H:i:s');
     } else {
         $this->date = date('Y-m-d H:i:s', strtotime($this->date));
     }
     $scope = $formName === null ? $this->formName() : $formName;
     if (isset($data[$scope])) {
         if (isset($data[$scope]['outgoing'])) {
             foreach ($data[$scope]['outgoing'] as $key => $outgoing) {
                 if (isset($this->outgoings[$key])) {
                     $loaded &= $this->outgoings[$key]->load($outgoing, '');
                 } else {
                     $out = new TransactionOutgoing();
                     $out->id = $key;
                     $loaded &= $out->load($outgoing, '');
                     $this->outgoings[] = $out;
                 }
             }
         }
         if (isset($data[$scope]['incoming'])) {
             foreach ($data[$scope]['incoming'] as $key => $incoming) {
                 if (isset($this->incomings[$key])) {
                     $loaded &= $this->incomings[$key]->load($incoming, '');
                 } else {
                     $in = new TransactionIncoming();
                     $in->id = $key;
                     $loaded &= $in->load($incoming, '');
                     $this->incomings[] = $in;
                 }
             }
         }
         if (isset($data[$scope]['expense'])) {
             foreach ($data[$scope]['expense'] as $key => $expense) {
                 if (isset($this->expenses[$key])) {
                     $loaded &= $this->expenses[$key]->load($expense, '');
                 } else {
                     $exp = new TransactionExpense();
                     $exp->id = $key;
                     $loaded &= $exp->load($expense, '');
                     $this->expenses[] = $exp;
                 }
             }
         }
     }
     return $loaded;
 }
开发者ID:alexshadie,项目名称:wallet,代码行数:49,代码来源:Transaction.php

示例10: 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

示例11: load

 public function load($data, $formName = null)
 {
     if (parent::load($data, $formName)) {
         $scope = $formName === null ? $this->formName() : $formName;
         if ($scope) {
             $data = $data[$scope];
         }
         $extraFields = $this->parseExtraField();
         foreach ($data as $attr => $value) {
             if (in_array($attr, $extraFields)) {
                 $this->{$attr} = $value;
             }
         }
         return true;
     } else {
         return false;
     }
 }
开发者ID:devbrom,项目名称:yii2-releases,代码行数:18,代码来源:ActiveRecordWithExtraFields.php

示例12: load

 public function load($data, $formName = null)
 {
     parent::load($data, $formName);
     if (!(Yii::$app->user->id > 0)) {
         $this->addError('seller_id');
         return;
     }
     //print_r($this); die();
     //print_r($data); die();
     //$this->id = $data['id'];
     $this->title = $data['title'];
     $this->description = $data['description'];
     $this->img_url = $data['img_url'];
     $this->price = (int) $data['price'];
     $this->seller_id = Yii::$app->user->id;
     $this->trash = 0;
     $this->categoriesArr = explode('_', $data['selected_categories']);
     foreach ($this->categoriesArr as $k => $v) {
         if (!((int) $v > 0)) {
             unset($this->categoriesArr[$k]);
         }
     }
 }
开发者ID:exelents,项目名称:test-fornekki,代码行数:23,代码来源:Items.php

示例13: saveSettingsModel

 /**
  * Save model of settings
  * @param ActiveRecord $model Model to save
  * @param array $requestParams Request parameters
  * @return bool
  */
 protected function saveSettingsModel(ActiveRecord $model, array $requestParams)
 {
     $success = false;
     $transaction = $model->getDb()->beginTransaction();
     try {
         $model->load($requestParams);
         if ($model->save()) {
             $transaction->commit();
             Yii::$app->interfaceSettings->refreshUserInterfaceSettings($model->user_id, $model->interface_id);
             $success = true;
         } else {
             throw new Exception();
         }
     } catch (Exception $e) {
         if ($transaction->isActive) {
             $transaction->rollBack();
         }
     }
     // trigger an event
     $this->trigger(self::EVENT_SAVE_SETTING, new ExtraDataEvent(['extraData' => ['model' => $model, 'success' => $success]]));
     return $success;
 }
开发者ID:kalibao,项目名称:magesko,代码行数:28,代码来源:Controller.php

示例14: load

 public function load($data, $formName = null)
 {
     if ($res = parent::load($data, $formName)) {
         $this->htmlAttributes = $data['htmlAttributes'];
     }
 }
开发者ID:igribov,项目名称:question-list,代码行数:6,代码来源:AnswerVariant.php

示例15: load

 /**
  * @inheritdoc
  */
 public function load($data, $formName = null)
 {
     return parent::load($data, $formName) && $this->loadValues($data);
 }
开发者ID:xyxdasnjss,项目名称:imshop,代码行数:7,代码来源:Facet.php


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