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


PHP ActiveRecord::setAttributes方法代码示例

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


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

示例1: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     if (!$this->modelClass) {
         throw new InvalidArgumentException('Param "modelClass" must be non-empty');
     }
     if (!is_subclass_of($this->modelClass, 'voskobovich\\base\\interfaces\\ModelInterface')) {
         throw new InvalidArgumentException('Param "modelClass" must be extend "voskobovich\\base\\interfaces\\ModelInterface"');
     }
     $this->_model = Yii::createObject($this->modelClass);
     $this->_model->setAttributes($this->initAttributes);
     parent::init();
 }
开发者ID:voskobovich,项目名称:yii2-base-toolkit,代码行数:15,代码来源:FormWrapper.php

示例2: setAttributes

 /**
  * rewrite set attributes, set relation data to relations, auto save at after save
  * @inheritdoc
  */
 public function setAttributes($values, $safeOnly = true)
 {
     if (is_array($values)) {
         foreach ($values as $name => $value) {
             $this->tryToSetRelation($name, $value);
         }
     }
     parent::setAttributes($values, $safeOnly);
 }
开发者ID:yinheark,项目名称:yincart2,代码行数:13,代码来源:ActiveRecord.php

示例3: setAttributes

 public function setAttributes($values, $safeOnly = true)
 {
     if (is_array($values)) {
         foreach ($values as $key => $value) {
             if (is_array($value)) {
                 unset($values[$key]);
             }
         }
     }
     parent::setAttributes($values, $safeOnly);
 }
开发者ID:noikiy,项目名称:wowewe,代码行数:11,代码来源:MAccessLogAll.php

示例4: setAttributes

 /**
  * Extends setAttributes to handle active date fields
  *
  * @param $values array
  * @param $safeOnly boolean
  */
 public function setAttributes($values, $safeOnly = true)
 {
     foreach ($this->widgetAttributes() as $fieldName => $className) {
         $className = '\\marsoltys\\yii2user\\components\\' . $className;
         if (isset($values[$fieldName]) && class_exists($className)) {
             $class = new $className();
             $arr = $this->widgetParams($fieldName);
             if ($arr) {
                 $newParams = $class->params;
                 $arr = (array) Json::decode($arr);
                 foreach ($arr as $p => $v) {
                     if (isset($newParams[$p])) {
                         $newParams[$p] = $v;
                     }
                 }
                 $class->params = $newParams;
             }
             if (method_exists($class, 'setAttributes')) {
                 $values[$fieldName] = $class->setAttributes($values[$fieldName], $this, $fieldName);
             }
         }
     }
     parent::setAttributes($values, $safeOnly);
 }
开发者ID:marsoltys,项目名称:yii2user,代码行数:30,代码来源:UActiveRecord.php

示例5: setAttributes

 public function setAttributes($attributes)
 {
     $model = $this->getModel();
     foreach ($attributes as $attribute => $value) {
         if (in_array($attribute, $this->pageAttributes)) {
             $model->title = $value;
             unset($attributes[$attribute]);
             continue;
         }
     }
     $model->save();
     $attributes['pageId'] = $model->id;
     parent::setAttributes($attributes);
 }
开发者ID:nurastana,项目名称:familyclinickz,代码行数:14,代码来源:Model.php

示例6: setAttributes

 /**
  * Check if some attributes uploaded via fileInput field
  * and assign them with UploadedFile
  *
  * @inheritdoc
  */
 public function setAttributes($values, $safeOnly = true)
 {
     parent::setAttributes($values, $safeOnly);
     // Looking only for file attributes (and fix null error on fly)
     if (is_array($values)) {
         $attributes = array_flip($safeOnly ? $this->safeAttributes() : $this->attributes());
         $class = StringHelper::basename(get_called_class());
         foreach ($values as $name => $value) {
             if (isset($attributes[$name])) {
                 if (isset($_FILES[$class]['name'][$name])) {
                     $uploadedFile = UploadedFile::getInstance($this, $name);
                     if ($uploadedFile) {
                         $this->{$name} = $uploadedFile;
                     } elseif (!$this->isNewRecord) {
                         $this->{$name} = $this->oldAttributes[$name];
                     }
                 }
             }
         }
     }
 }
开发者ID:webvimark,项目名称:components,代码行数:27,代码来源:BaseActiveRecord.php

示例7: _setValue

 /**
  * @inheritDoc
  */
 protected function _setValue(ActiveRecord $model, $value)
 {
     /** @var ActiveRecord $model */
     $model->setAttributes([$this->attributeName => $value]);
     return true;
 }
开发者ID:nanodesu88,项目名称:easyii,代码行数:9,代码来源:ActiveDataColumn.php

示例8: setAttributes

 /**
  * (non-PHPdoc)
  * @see \yii\base\Model::setAttributes()
  * @throws Exception if the current record is read only
  */
 public function setAttributes($values, $safeOnly = true)
 {
     if ($this->getReadOnly()) {
         throw new Exception('Attempting to set attributes on a read only ' . Tools::getClassName($this) . ' model');
     }
     parent::setAttributes($values, $safeOnly);
 }
开发者ID:fangface,项目名称:yii2-concord,代码行数:12,代码来源:ActiveRecord.php


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