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


PHP CModel::__get方法代码示例

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


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

示例1: __get

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

示例2: __get

 /**
  * PHP getter magic method.
  *
  * @param string $name
  *
  * @return mixed
  */
 public function __get($name)
 {
     if (in_array($name, $this->attributeNames())) {
         return $this->getAttribute($name);
     } else {
         return parent::__get($name);
     }
 }
开发者ID:andyra,项目名称:tes,代码行数:15,代码来源:BaseModel.php

示例3: __get

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

示例4: __get

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

示例5: __get

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

示例6: __get

 public function __get($name)
 {
     if (strpos($name, '[')) {
         $basePropertyName = substr($name, 0, strpos($name, '['));
         $index = substr($name, strpos($name, '[') + 1);
         if (property_exists($this, $basePropertyName)) {
             return ArrayUtil::getNestedValue($this->{$basePropertyName}, $index);
         }
     }
     return parent::__get($name);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:11,代码来源:BuilderElementEditableModelForm.php

示例7: __get

 /**
  * (non-PHPdoc)
  * @see yii/framework/CComponent::__get()
  */
 public function __get($name)
 {
     if (isset($this->_attributes[$name])) {
         return $this->_attributes[$name];
     } elseif (isset($this->_related[$name])) {
         return $this->_related[$name];
     } elseif (array_key_exists($name, $this->relations())) {
         return $this->_related[$name] = $this->getRelated($name);
     } else {
         try {
             return parent::__get($name);
         } catch (CException $e) {
             return null;
         }
     }
 }
开发者ID:rubipikachu,项目名称:xoso-lechung,代码行数:20,代码来源:EMongoModel.php

示例8: __get

 /**
  * @see yii/framework/CComponent::__get()
  * @param string $name
  * @return mixed
  */
 public function __get($name)
 {
     if (isset($this->_attributes[$name])) {
         return $this->_attributes[$name];
     }
     if (isset($this->_related[$name])) {
         return $this->_related[$name];
     }
     if (array_key_exists($name, $this->relations())) {
         return $this->_related[$name] = $this->getRelated($name);
     }
     try {
         return parent::__get($name);
     } catch (CException $e) {
         $getter = 'get' . $name;
         if (method_exists($this, $getter)) {
             throw $e;
         } elseif (strncasecmp($name, 'on', 2) === 0 && method_exists($this, $name)) {
             throw $e;
         }
         return null;
     }
 }
开发者ID:pvassiliou,项目名称:MongoYii,代码行数:28,代码来源:EMongoModel.php

示例9: __get

 /**
  * PHP getter magic method.
  * This method is overridden so that attributes can be accessed like properties.
  * @param string $name property name
  * @return mixed property value
  */
 public function __get($name)
 {
     if (isset($this->_attributes[$name])) {
         return $this->_attributes[$name];
         //   	} else if(isset($this->_related[$name])) {
         //   			return $this->_related[$name];
     } else {
         return parent::__get($name);
     }
 }
开发者ID:laiello,项目名称:skrapshcnul,代码行数:16,代码来源:EGithubModel.php

示例10: __get

 /**
  * @since v1.0.8
  */
 public function __get($name)
 {
     if ($this->hasEmbeddedDocuments() && isset(self::$_embeddedConfig[get_class($this)][$name])) {
         // 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);
     } else {
         return parent::__get($name);
     }
 }
开发者ID:nmalservet,项目名称:biocap,代码行数:18,代码来源:EMongoEmbeddedDocument.php

示例11: __get

 /**
  * PHP getter magic method.
  * This method is overridden so that node/relationship properties can be accessed.
  * @param string $name property name
  * @return mixed property value
  * @see getAttribute
  */
 public function __get($name)
 {
     if (isset($this->_attributes[$name])) {
         return $this->_attributes[$name];
     } else {
         if (isset($this->getMetaData()->properties[$name])) {
             return null;
         } else {
             return parent::__get($name);
         }
     }
 }
开发者ID:rualatngua,项目名称:ActiveResource,代码行数:19,代码来源:EActiveResource.php

示例12: __get

 /**
  * PHP getter magic method.
  * This method is overridden so that Resource Model attributes can be accessed like properties.
  * @param string $name property name
  * @return mixed property value
  * @see getAttribute
  */
 public function __get($name)
 {
     if (isset($this->_attributes[$name])) {
         return $this->_attributes[$name];
     } elseif ($this->getResourceSchema()->hasAttribute($name)) {
         return null;
     } elseif (isset($this->_linked[$name])) {
         return $this->_linked[$name];
     } elseif (isset($this->_links[$name])) {
         return $this->getLinked($name);
     } else {
         return parent::__get($name);
     }
 }
开发者ID:codemix,项目名称:restyii,代码行数:21,代码来源:Model.php

示例13: __get

 /**
  * Волшебный геттер
  * @param type $name
  */
 public function __get($name)
 {
     // проверка на наличие маппинга свойства на поле БД
     $mapping = $this->fieldsMapping();
     if (array_key_exists($name, $mapping)) {
         $name = $mapping[$name];
     }
     // проверяем, не обычное ли это поле
     if (array_key_exists($name, $this->getRecord()->getItems())) {
         // обходной маневр для конвертации mysql-дат в отечественные
         $properties = $this->fieldsProperty();
         if (array_key_exists($name, $properties)) {
             $property = $properties[$name];
             if (array_key_exists("type", $property)) {
                 if ($property["type"] == FIELD_MYSQL_DATE) {
                     $value = $this->getRecord()->getItemValue($name);
                     if (strpos($value, "0000-00-00") !== false) {
                         return "";
                     }
                     return date($property["format"], strtotime($value));
                 }
             }
         }
         return $this->getRecord()->getItemValue($name);
     }
     // поле необычное.
     $relations = $this->relations();
     if (array_key_exists($name, $relations)) {
         $relation = $relations[$name];
         // разрешим не указывать
         if (!array_key_exists("storageProperty", $relation)) {
             $relation["storageProperty"] = "_" . $name;
         }
         if ($relation['relationPower'] == RELATION_HAS_ONE) {
             $private = $relation['storageProperty'];
             if (is_null($this->{$private})) {
                 $key_field = $relation['storageField'];
                 $key_value = $this->{$key_field};
                 $useManager = true;
                 if (array_key_exists("targetClass", $relation)) {
                     $targetClass = $relation["targetClass"];
                     $useManager = false;
                 } else {
                     $managerClass = $relation['managerClass'];
                     $managerGetter = $relation['managerGetObject'];
                 }
                 if ($useManager) {
                     $obj = $managerClass::$managerGetter($key_value);
                 } else {
                     $targetClass = "get" . mb_substr($targetClass, 1);
                     $obj = CBaseManager::$targetClass($key_value);
                 }
                 $this->{$private} = $obj;
             }
             return $this->{$private};
         } elseif ($relation['relationPower'] == RELATION_HAS_MANY) {
             $private = $relation['storageProperty'];
             /**
              * Проверим, вдруг разрешено использование кэш
              * и данные кэше уже есть
              */
             $useCache = false;
             if (array_key_exists("useCache", $relation)) {
                 $useCache = $relation["useCache"];
             }
             if ($useCache) {
                 $cacheKey = get_class($this) . "_property_" . $name . "_" . $this->getId();
                 if (CApp::getApp()->cache->hasCache($cacheKey)) {
                     $valueFromCache = CApp::getApp()->cache->get($cacheKey);
                     $this->{$private} = $valueFromCache;
                 }
             }
             if (is_null($this->{$private})) {
                 $table = $relation['storageTable'];
                 $condition = $relation['storageCondition'];
                 $useManager = true;
                 if (array_key_exists("targetClass", $relation)) {
                     $targetClass = $relation["targetClass"];
                     $useManager = false;
                 } else {
                     $managerClass = $relation['managerClass'];
                     $managerGetter = $relation['managerGetObject'];
                 }
                 $managerOrder = null;
                 if (array_key_exists("managerOrder", $relation)) {
                     $managerOrder = $relation['managerOrder'];
                 }
                 $this->{$private} = new CArrayList();
                 foreach (CActiveRecordProvider::getWithCondition($table, $condition, $managerOrder)->getItems() as $item) {
                     if ($useManager) {
                         $obj = $managerClass::$managerGetter($item->getId());
                     } else {
                         $obj = new $targetClass($item);
                     }
                     if (!is_null($obj)) {
                         if (is_object($obj)) {
//.........这里部分代码省略.........
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:101,代码来源:CActiveModel.class.php

示例14: __get

 /**
  * PHP getter magic method.
  * This method is overridden so that AR attributes can be accessed like properties.
  * @param string $name property name
  * @return mixed property value
  * @see getAttribute
  */
 public function __get($name)
 {
     if (property_exists($this, $name)) {
         return $this->{$name};
     } else {
         if (isset($this->_attributes[$name])) {
             return $this->_attributes[$name];
         } else {
             if (isset($this->relations[$name])) {
                 return $this->relations[$name];
             } else {
                 if (isset($this->relations()[$name])) {
                     return $this->getRelated($name);
                 } else {
                     return parent::__get($name);
                 }
             }
         }
     }
 }
开发者ID:edwardstock,项目名称:yii-mongo-record,代码行数:27,代码来源:MongoRecord.php

示例15: __get

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


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