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


PHP Model::__set方法代碼示例

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


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

示例1: __set

 public function __set($fieldName, $value)
 {
     // Check if the property is public
     try {
         $R = new \ReflectionClass($this);
         $property = $R->getProperty($fieldName);
     } catch (\ReflectionException $e) {
         // Property doesn't exist, call the stupid parent
         return parent::__set($fieldName, $value);
     }
     if ($property->isPublic()) {
         // Again, call your parents
         return parent::__set($fieldName, $value);
     } else {
         // Property exists, and it's private / protected
         try {
             // Maybe there is a setter for this one?
             $nameArr = explode('_', $fieldName);
             $methodName = 'set';
             foreach ($nameArr as $vv) {
                 $methodName .= ucwords($vv);
             }
             $method = $R->getMethod($methodName);
             // Okay, no exception, let's call it
             return $this->{$methodName}($value);
         } catch (\ReflectionException $up) {
             // Just let it go through
             throw $up;
         }
     }
 }
開發者ID:abc2001x,項目名稱:phalcon_mode,代碼行數:31,代碼來源:BaseModel.php

示例2: __set

 public function __set($property, $value)
 {
     if (is_object($property) || is_array($property)) {
         return parent::__set($property, $value);
     }
     $this->_dataAccess[$property] = $value;
 }
開發者ID:skullab,項目名稱:area51,代碼行數:7,代碼來源:BaseModel.php

示例3: __set

 /**
  * Magic method to use attribute in snake_case
  * For example $ex->a_method = $value is same as $ex->setAMethod($value)
  * @param string $property The property in snake_case
  * @param array $params The value that will be passed to set method
  * @return mixed Call the method if it exists, otherwise call parent __set() method
  */
 public function __set($property, $params)
 {
     $method = 'set' . Phalcon\Text::camelize($property);
     if (method_exists($this, $method)) {
         return $this->{$method}($params);
     }
     parent::__set($property, $params);
 }
開發者ID:wataridori,項目名稱:bphalcon,代碼行數:15,代碼來源:BModel.php


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