當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ActiveRecord::__set方法代碼示例

本文整理匯總了PHP中yii\db\ActiveRecord::__set方法的典型用法代碼示例。如果您正苦於以下問題:PHP ActiveRecord::__set方法的具體用法?PHP ActiveRecord::__set怎麽用?PHP ActiveRecord::__set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在yii\db\ActiveRecord的用法示例。


在下文中一共展示了ActiveRecord::__set方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __set

 /**
  * @inheritdoc
  */
 public function __set($name, $value)
 {
     if ($this->tryToSetRelation($name, $value)) {
         return;
     }
     parent::__set($name, $value);
 }
開發者ID:yinheark,項目名稱:yincart2,代碼行數:10,代碼來源:ActiveRecord.php

示例2: __set

 public function __set($name, $value)
 {
     if ($name === 'history') {
         return $this->setHistory($value);
     }
     return parent::__set($name, $value);
 }
開發者ID:serhiobb,項目名稱:RGK-test,代碼行數:7,代碼來源:Url.php

示例3: __set

 public function __set($name, $value)
 {
     if (isset($this->_pivotAttributes[$name])) {
         throw new Exception("Attribute '{$name}' is attached from junction table and read-only");
     }
     parent::__set($name, $value);
 }
開發者ID:alexinator1,項目名稱:yii2-jta,代碼行數:7,代碼來源:ActiveRecord.php

示例4: __set

 /**
  * @inheritdoc
  */
 public function __set($name, $newValue)
 {
     if ($this->hasMetaAttribute($name)) {
         $this->setMeta($name, $newValue);
     } else {
         parent::__set($name, $newValue);
     }
 }
開發者ID:NewPaltzKarateAcademy,項目名稱:KIMS,代碼行數:11,代碼來源:MetaModel.php

示例5: __set

 /**
  * @inheritdoc
  */
 public function __set($name, $value)
 {
     if ($this->_i18n_enabled && in_array($name, $this->_getI18NAttributes())) {
         $this->{$name} = $value;
     } else {
         parent::__set($name, $value);
     }
 }
開發者ID:olegantoniuk,項目名稱:components,代碼行數:11,代碼來源:BaseActiveRecord.php

示例6: __set

 public function __set($name, $value)
 {
     if (!in_array($name, $this->attributes()) && !empty($this->app->elements[$name]) && ($behavior = $this->getBehavior($this->app->elements[$name]->type)) !== null) {
         return $behavior->setValue($name, $value);
     } else {
         return parent::__set($name, $value);
     }
 }
開發者ID:worstinme,項目名稱:yii2-zoo,代碼行數:8,代碼來源:Items.php

示例7: __set

 public function __set($name, $value)
 {
     if (in_array($name, $this->jsonParams)) {
         return $this->setJsonParams($name, $value);
     } else {
         return parent::__set($name, $value);
     }
 }
開發者ID:worstinme,項目名稱:yii2-z-cart,代碼行數:8,代碼來源:CartOrders.php

示例8: __set

 public function __set($name, $value)
 {
     try {
         parent::__set($name, $value);
     } catch (UnknownPropertyException $e) {
         if (isset($this->_transformers[$name])) {
             $this->_transformers[$name]->transformTo($value);
         } else {
             parent::__set(static::prop2col($name), $value);
         }
     }
 }
開發者ID:tsyrya,項目名稱:mybriop,代碼行數:12,代碼來源:EntityBase.php

示例9: __set

 /**
  * Override __get of yii\db\ActiveRecord
  *
  * @param string $name the property name or the event name
  * @param mixed $value the property value
  */
 public function __set($name, $value)
 {
     if ($this->hasAttribute($name)) {
         parent::__set($name, $value);
     } else {
         if ($this->autoSaveMetaFields && !$this->isNewRecord) {
             $this->setMetaAttribute($name, $value);
         } else {
             $this->enqueueMetaUpdate($name, $value);
         }
     }
 }
開發者ID:mipotech,項目名稱:yii2-meta-activerecord,代碼行數:18,代碼來源:MetaActiveRecord.php

示例10: __set

 public function __set($name, $value)
 {
     if (in_array($name, $this->getDefaultFields())) {
         return parent::__set($name, $value);
     }
     if (in_array($name, $this->getSkipFields())) {
         return [];
     }
     $rules = Json::decode($this->rules);
     if (!$rules) {
         $rules = [];
     }
     $rules[$name] = $value;
     $this->rules = Json::encode($rules);
 }
開發者ID:mirocow,項目名稱:yii2-eav,代碼行數:15,代碼來源:EavAttributeRule.php

示例11: setAttribute

 /**
  * Sets a model attribute.
  *
  * @param string $name attribute name, use dotted notation for structured attributes.
  * @param mixed $value the attribute value. A value of null effectively unsets the attribute.
  */
 public function setAttribute($name, $value)
 {
     try {
         parent::__set($name, $value);
         return;
     } catch (UnknownPropertyException $ignore) {
     }
     $path = explode('.', $name);
     $ref =& $this->_dynamicAttributes;
     // Walk forwards through $path to find the deepest key already set.
     do {
         $key = $path[0];
         if (isset($ref[$key])) {
             $ref =& $ref[$key];
             array_shift($path);
         } else {
             break;
         }
     } while ($path);
     // If the whole path already existed then we can just set it.
     if (!$path) {
         $ref = $value;
         return;
     }
     // There is remaining path so we have to set a new leaf with the first
     // part of the remaining path as key. But first, if there is any path
     // beyond that then we need build an array to set as the new leaf value.
     while (count($path) > 1) {
         $key = array_pop($path);
         $value = [$key => $value];
     }
     $ref[$path[0]] = $value;
 }
開發者ID:nineinchnick,項目名稱:yii2-dynamic-ar,代碼行數:39,代碼來源:DynamicActiveRecord.php

示例12: __set

 public function __set($key, $value)
 {
     if ($key = $this->hasKey($key)) {
         parent::__set($key, $value);
     }
 }
開發者ID:JiltImageBoard,項目名稱:jilt-backend,代碼行數:6,代碼來源:ARExtended.php

示例13: __set

 /**
  * @inheritdoc
  */
 public function __set($name, $value)
 {
     if ($name === 'group') {
         $this->_schema = static::$schemaDefinition[$value];
     }
     if ($this->_schema && isset($this->_schema[$name])) {
         $this->_values[$name] = $value;
     } else {
         parent::__set($name, $value);
     }
 }
開發者ID:sangkil,項目名稱:application,代碼行數:14,代碼來源:GlobalConfig.php

示例14: __set

 public function __set($name, $value)
 {
     $extraFields = $this->parseExtraField();
     if (in_array($name, $extraFields)) {
         $this->_extraFields[$name] = $value;
     } else {
         parent::__set($name, $value);
     }
 }
開發者ID:devbrom,項目名稱:yii2-releases,代碼行數:9,代碼來源:ActiveRecordWithExtraFields.php

示例15: __set

 /**
  * PHP setter magic method.
  * This method is overridden so that AR attributes can be accessed like properties,
  * but only if the current model is not read only
  * @param string $name property name
  * @param mixed $value property value
  * @throws Exception if the current record is read only
  */
 public function __set($name, $value)
 {
     if ($this->getReadOnly()) {
         throw new Exception('Attempting to set attribute `' . $name . '` on a read only ' . Tools::getClassName($this) . ' model');
     }
     parent::__set($name, $value);
 }
開發者ID:fangface,項目名稱:yii2-concord,代碼行數:15,代碼來源:ActiveRecord.php


注:本文中的yii\db\ActiveRecord::__set方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。