本文整理汇总了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);
}
}
示例2: setAttribute
public function setAttribute($name, $value)
{
parent::setAttribute(DataHelper::camelToSnake($name), $value);
}
示例3: setAttribute
public function setAttribute($name, $value)
{
if (parent::setAttribute($name, $value)) {
if ($name === 'eav_set_id') {
$this->refreshEavAttributes();
}
return true;
}
return false;
}
示例4: setAttribute
public function setAttribute($name, $value)
{
if ($name == "password") {
$this->markAsPasswordChanged();
}
parent::setAttribute($name, $value);
}
示例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();
}
//}
}
示例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);
}