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


PHP CActiveRecord::setAttribute方法代碼示例

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


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

示例1: setAttribute

 /**
  * need protected $_attributes
  *
  * @param string $name_key
  * @param mixed $value
  * @return bool
  */
 public function setAttribute($name_key, $value)
 {
     $pos = strpos($name_key, '[');
     if ($pos) {
         $key = substr($name_key, $pos + 1, -1);
         $name = substr($name_key, 0, $pos);
         if (property_exists($this, $name)) {
             $this->{$name}[$key] = $value;
         } elseif (isset($this->getMetaData()->columns[$name])) {
             $this->_attributes[$name][$key] = $value;
         } else {
             return false;
         }
         return true;
     } else {
         return parent::setAttribute($name_key, $value);
     }
 }
開發者ID:isuvorov,項目名稱:yiirest,代碼行數:25,代碼來源:RestActiveRecord.php

示例2: setAttribute

 public function setAttribute($name, $value)
 {
     parent::setAttribute(DataHelper::camelToSnake($name), $value);
 }
開發者ID:xexys,項目名稱:xca-backend,代碼行數:4,代碼來源:ActiveRecord.php

示例3: setAttribute

 public function setAttribute($name, $value)
 {
     if (parent::setAttribute($name, $value)) {
         if ($name === 'eav_set_id') {
             $this->refreshEavAttributes();
         }
         return true;
     }
     return false;
 }
開發者ID:kuzmina-mariya,項目名稱:unizaro-spa,代碼行數:10,代碼來源:EavActiveRecord.php

示例4: setAttribute

 public function setAttribute($name, $value)
 {
     if ($name == "password") {
         $this->markAsPasswordChanged();
     }
     parent::setAttribute($name, $value);
 }
開發者ID:kittolau,項目名稱:gcm,代碼行數:7,代碼來源:User.php

示例5: inheritvalues

 /**
  * This method is used to at create/copy or move. If the last $inherit attribute is true
  * the nodes under current and current also will inherit the values from the new parent.
  * @param CActiveRecord $current node that is created/copied or moved
  * @param CActiveRecord $parent the new parent in either senario
  */
 public function inheritvalues($current, $parent)
 {
     //        $differentparent = $parent->getAttribute($this->identity)!=$current->parent()->getAttribute($this->identity);
     //        if ( $differentparent ) {
     foreach ($this->inherit as $attr) {
         $current->setAttribute($attr, $parent->getAttribute($attr));
     }
     $current->saveNode();
     $descendants = $current->descendants()->findAll();
     foreach ($descendants as $i => $node) {
         foreach ($this->inherit as $attr) {
             $node->setAttribute($attr, $parent->getAttribute($attr));
         }
         $node->saveNode();
     }
     //}
 }
開發者ID:samdark,項目名稱:EJNestedTreeActions,代碼行數:23,代碼來源:EBehavior.php

示例6: setAttribute

 /**
  * Sets the attribute value.
  *
  * @param string $name the attribute name
  * @param mixed $value the attribute value
  * @param bool $cast whether to cast the value to the appropriate type, defaults to true
  *
  * @return boolean whether the attribute exists and the assignment is conducted successfully
  */
 public function setAttribute($name, $value, $cast = true)
 {
     if ($cast) {
         if (property_exists($this, $name)) {
             $value = $this->castAttribute($name, $value);
         } elseif (isset($this->getMetaData()->columns[$name])) {
             $value = $this->castAttribute($name, $value);
         }
     }
     return parent::setAttribute($name, $value);
 }
開發者ID:codemix,項目名稱:restyii,代碼行數:20,代碼來源:ActiveRecord.php


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