当前位置: 首页>>代码示例>>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;未经允许,请勿转载。