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


PHP CModel::__set方法代码示例

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


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

示例1: __set

 public function __set($name, $value)
 {
     if (array_key_exists($name, $this->data)) {
         $this->data[$name] = $value;
     } else {
         parent::__set($name, $value);
     }
 }
开发者ID:eneelkant,项目名称:oprecx-project,代码行数:8,代码来源:RecruitmentElement.php

示例2: __set

 public function __set($name, $value)
 {
     if ($this->hasAttribute($name, $value)) {
         $this->setAttribute($name, $value);
     } else {
         parent::__set($name, $value);
     }
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:8,代码来源:AmorphousModel.php

示例3: __set

 public function __set($name, $value)
 {
     if (in_array($name, $this->attributeNames())) {
         $this->_attributes[$name] = $value;
     } else {
         parent::__set($name, $value);
     }
 }
开发者ID:cebe,项目名称:chive,代码行数:8,代码来源:SqlModel.php

示例4: __set

 /**
  * @see CComponent::__set()
  * @param string $name
  * @param mixed $value
  * @return mixed
  */
 public function __set($name, $value)
 {
     if (isset($this->_related[$name]) || array_key_exists($name, $this->relations())) {
         return $this->_related[$name] = $value;
     }
     // This might be a little unperformant actually since Yiis own active record detects
     // If an attribute can be set first to ensure speed of accessing local variables...hmmm
     try {
         return parent::__set($name, $value);
     } catch (CException $e) {
         return $this->setAttribute($name, $value);
     }
 }
开发者ID:pvassiliou,项目名称:MongoYii,代码行数:19,代码来源:EMongoModel.php

示例5: __set

 public function __set($name, $value)
 {
     if ($this->setAttribute($name, $value) === false) {
         if (isset($this->getMetaData()->relations[$name])) {
             $this->_related[$name] = $value;
         } else {
             parent::__set($name, $value);
         }
     }
 }
开发者ID:smokeelow,项目名称:faicore,代码行数:10,代码来源:yiilite.php

示例6: __set

 /**
  * PHP setter magic method.
  *
  * @param string $name
  * @param mixed  $value
  *
  * @return mixed
  */
 public function __set($name, $value)
 {
     if ($this->setAttribute($name, $value) === false) {
         parent::__set($name, $value);
     }
 }
开发者ID:andyra,项目名称:tes,代码行数:14,代码来源:BaseModel.php

示例7: __set

 /**
  * @since v1.0.8
  */
 public function __set($name, $value)
 {
     if ($this->hasEmbeddedDocuments() && isset(self::$_embeddedConfig[get_class($this)][$name])) {
         if (is_array($value)) {
             // Late creation of embedded documents on first access
             if (is_null($this->_embedded->itemAt($name))) {
                 $docClassName = self::$_embeddedConfig[get_class($this)][$name];
                 $doc = new $docClassName($this->getScenario());
                 $doc->setOwner($this);
                 $this->_embedded->add($name, $doc);
             }
             return $this->_embedded->itemAt($name)->attributes = $value;
         } else {
             if ($value instanceof EMongoEmbeddedDocument) {
                 return $this->_embedded->add($name, $value);
             }
         }
     } else {
         parent::__set($name, $value);
     }
 }
开发者ID:nmalservet,项目名称:biocap,代码行数:24,代码来源:EMongoEmbeddedDocument.php

示例8: __set

 /**
  * PHP setter magic method.
  * This method is overridden so that MongoDB document can be accessed like properties.
  * @param string property name
  * @param mixed property value
  */
 public function __set($name, $value)
 {
     if ($name === 'id') {
         $this->_document['_id'] = $value;
     } elseif (array_key_exists($name, $this->_document)) {
         $this->_document[$name] = $value;
     } else {
         parent::__set($name, $value);
     }
 }
开发者ID:jerrylsxu,项目名称:MongoRecord,代码行数:16,代码来源:MongoRecord.php

示例9: __set

 /**
  * PHP setter magic method.
  * This method is overridden so that Resource Model attributes can be accessed like properties.
  * @param string $name property name
  * @param mixed $value property value
  * @return void
  */
 public function __set($name, $value)
 {
     if ($this->setAttribute($name, $value) === false) {
         if (isset($this->_links[$name])) {
             $this->_linked[$name] = $value;
         } else {
             parent::__set($name, $value);
         }
     }
 }
开发者ID:codemix,项目名称:restyii,代码行数:17,代码来源:Model.php

示例10: __set

 /**
  * Волшебный сеттер
  * @param type $name
  * @param type $value
  */
 public function __set($name, $value)
 {
     // на случай наличия маппинга поля
     $mapping = $this->fieldsMapping();
     if (array_key_exists($name, $mapping)) {
         $name = $mapping[$name];
     }
     // сначала проверим какого типа пришло значение
     // просто setItemValue() вызываем только в случае
     // простых типов данных
     if (!is_object($value)) {
         if ($this->getDbTable()->getFields()->hasElement($name)) {
             $this->getRecord()->setItemValue($name, $value);
             if (!array_key_exists($name, $this->getRecord()->getItems())) {
                 $trace = debug_backtrace();
                 trigger_error('Неопределенное свойство в __set(): ' . $name . ' в файле ' . $trace[0]['file'] . ' на строке ' . $trace[0]['line'], E_USER_NOTICE);
                 return null;
             }
         }
     } else {
         // пришел объект
         // объекты складываем в соответствии с relations()
         if (!array_key_exists($name, $this->relations())) {
             // обратимся к родительскому методу
             parent::__set($name, $value);
             return;
         }
         $relations = $this->relations();
         $relation = $relations[$name];
         // разрешим не указывать
         if (!array_key_exists("storageProperty", $relation)) {
             $relation["storageProperty"] = "_" . $name;
         }
         // определяем, какой тип связи
         if ($relation['relationPower'] == RELATION_HAS_ONE) {
             // сначала кладем объект в приватное свойство
             $private = $relation['storageProperty'];
             $this->{$private} = $value;
             // теперь в поле кладем id объекта
             $field = $relation['storageField'];
             $this->getRecord()->setItemValue($field, $value->getId());
         }
     }
 }
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:49,代码来源:CActiveModel.class.php

示例11: __set

 /**
  * Sets value of a component property.
  * Do not call this method. This is a PHP magic method that we override
  * to allow using the following syntax to set a property or attach an event handler
  * <pre>
  * $this->propertyName=$value;
  * $this->eventName=$callback;
  * </pre>
  * @param string $name the property name or the event name
  * @param mixed  $value the property value or callback
  * @return mixed
  * @throws \CException if the property/event is not defined or the property is read only.
  * @see __get
  */
 public function __set($name, $value)
 {
     if (array_key_exists($name, $this->_attributes)) {
         $this->_attributes[$name] = $value;
     } else {
         parent::__set($name, $value);
     }
 }
开发者ID:icron,项目名称:yii-dynamic-model,代码行数:22,代码来源:DynamicModel.php

示例12: __set

 public function __set($name, $value)
 {
     if (isset($this->_attributes[$name])) {
         $this->_values[$name] = $value;
     } else {
         parent::__set($name, $value);
     }
 }
开发者ID:rosko,项目名称:Tempo-CMS,代码行数:8,代码来源:VirtualModel.php


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