本文整理汇总了PHP中yii\db\ActiveRecord::__set方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecord::__set方法的具体用法?PHP ActiveRecord::__set怎么用?PHP ActiveRecord::__set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\db\ActiveRecord
的用法示例。
在下文中一共展示了ActiveRecord::__set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __set
/**
* @inheritdoc
*/
public function __set($name, $value)
{
if ($this->tryToSetRelation($name, $value)) {
return;
}
parent::__set($name, $value);
}
示例2: __set
public function __set($name, $value)
{
if ($name === 'history') {
return $this->setHistory($value);
}
return parent::__set($name, $value);
}
示例3: __set
public function __set($name, $value)
{
if (isset($this->_pivotAttributes[$name])) {
throw new Exception("Attribute '{$name}' is attached from junction table and read-only");
}
parent::__set($name, $value);
}
示例4: __set
/**
* @inheritdoc
*/
public function __set($name, $newValue)
{
if ($this->hasMetaAttribute($name)) {
$this->setMeta($name, $newValue);
} else {
parent::__set($name, $newValue);
}
}
示例5: __set
/**
* @inheritdoc
*/
public function __set($name, $value)
{
if ($this->_i18n_enabled && in_array($name, $this->_getI18NAttributes())) {
$this->{$name} = $value;
} else {
parent::__set($name, $value);
}
}
示例6: __set
public function __set($name, $value)
{
if (!in_array($name, $this->attributes()) && !empty($this->app->elements[$name]) && ($behavior = $this->getBehavior($this->app->elements[$name]->type)) !== null) {
return $behavior->setValue($name, $value);
} else {
return parent::__set($name, $value);
}
}
示例7: __set
public function __set($name, $value)
{
if (in_array($name, $this->jsonParams)) {
return $this->setJsonParams($name, $value);
} else {
return parent::__set($name, $value);
}
}
示例8: __set
public function __set($name, $value)
{
try {
parent::__set($name, $value);
} catch (UnknownPropertyException $e) {
if (isset($this->_transformers[$name])) {
$this->_transformers[$name]->transformTo($value);
} else {
parent::__set(static::prop2col($name), $value);
}
}
}
示例9: __set
/**
* Override __get of yii\db\ActiveRecord
*
* @param string $name the property name or the event name
* @param mixed $value the property value
*/
public function __set($name, $value)
{
if ($this->hasAttribute($name)) {
parent::__set($name, $value);
} else {
if ($this->autoSaveMetaFields && !$this->isNewRecord) {
$this->setMetaAttribute($name, $value);
} else {
$this->enqueueMetaUpdate($name, $value);
}
}
}
示例10: __set
public function __set($name, $value)
{
if (in_array($name, $this->getDefaultFields())) {
return parent::__set($name, $value);
}
if (in_array($name, $this->getSkipFields())) {
return [];
}
$rules = Json::decode($this->rules);
if (!$rules) {
$rules = [];
}
$rules[$name] = $value;
$this->rules = Json::encode($rules);
}
示例11: setAttribute
/**
* Sets a model attribute.
*
* @param string $name attribute name, use dotted notation for structured attributes.
* @param mixed $value the attribute value. A value of null effectively unsets the attribute.
*/
public function setAttribute($name, $value)
{
try {
parent::__set($name, $value);
return;
} catch (UnknownPropertyException $ignore) {
}
$path = explode('.', $name);
$ref =& $this->_dynamicAttributes;
// Walk forwards through $path to find the deepest key already set.
do {
$key = $path[0];
if (isset($ref[$key])) {
$ref =& $ref[$key];
array_shift($path);
} else {
break;
}
} while ($path);
// If the whole path already existed then we can just set it.
if (!$path) {
$ref = $value;
return;
}
// There is remaining path so we have to set a new leaf with the first
// part of the remaining path as key. But first, if there is any path
// beyond that then we need build an array to set as the new leaf value.
while (count($path) > 1) {
$key = array_pop($path);
$value = [$key => $value];
}
$ref[$path[0]] = $value;
}
示例12: __set
public function __set($key, $value)
{
if ($key = $this->hasKey($key)) {
parent::__set($key, $value);
}
}
示例13: __set
/**
* @inheritdoc
*/
public function __set($name, $value)
{
if ($name === 'group') {
$this->_schema = static::$schemaDefinition[$value];
}
if ($this->_schema && isset($this->_schema[$name])) {
$this->_values[$name] = $value;
} else {
parent::__set($name, $value);
}
}
示例14: __set
public function __set($name, $value)
{
$extraFields = $this->parseExtraField();
if (in_array($name, $extraFields)) {
$this->_extraFields[$name] = $value;
} else {
parent::__set($name, $value);
}
}
示例15: __set
/**
* PHP setter magic method.
* This method is overridden so that AR attributes can be accessed like properties,
* but only if the current model is not read only
* @param string $name property name
* @param mixed $value property value
* @throws Exception if the current record is read only
*/
public function __set($name, $value)
{
if ($this->getReadOnly()) {
throw new Exception('Attempting to set attribute `' . $name . '` on a read only ' . Tools::getClassName($this) . ' model');
}
parent::__set($name, $value);
}