本文整理汇总了PHP中CActiveRecord::__set方法的典型用法代码示例。如果您正苦于以下问题:PHP CActiveRecord::__set方法的具体用法?PHP CActiveRecord::__set怎么用?PHP CActiveRecord::__set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CActiveRecord
的用法示例。
在下文中一共展示了CActiveRecord::__set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __set
public function __set($name, $value)
{
if (array_key_exists($name, $this->_langAttributes)) {
$this->_langAttributes[$name] = $value;
} else {
parent::__set($name, $value);
}
}
示例2: __set
public function __set($name, $value)
{
if ($name === 'password') {
$value = CPasswordHelper::hashPassword($value);
}
parent::__set($name, $value);
// TODO: Change the autogenerated stub
}
示例3: __set
public function __set($name, $value)
{
if (isset($this->_fieldsArias[$name])) {
parent::__set($this->_fieldsArias[$name], $value);
} else {
parent::__set($name, $value);
}
}
示例4: __set
/**
* PHP setter magic method.
* This method is overridden so that AR attributes can be accessed like properties.
* @param string $name property name
* @param mixed $value property value
*/
public function __set($name, $value)
{
$setter = 'set' . ucfirst($name);
if (method_exists($this, $setter)) {
return $this->{$setter}($value);
}
parent::__set($name, $value);
}
示例5: __set
/**
* 复杂类型字段赋值实现
*/
public function __set($name, $value)
{
if (in_array($name, $this->complexAttributes())) {
$value = CJSON::encode($value);
parent::__set($name, $value);
} else {
parent::__set($name, $value);
}
}
示例6: __set
public function __set($name, $value)
{
$upper = strtoupper($name);
if ($this->hasAttribute($upper) || $this->hasRelated($upper)) {
return parent::__set($upper, $value);
} else {
return parent::__set($name, $value);
}
}
示例7: __set
public function __set($name, $value)
{
$e;
try {
return parent::__set($name, $value);
} catch (\Exception $ex) {
$e = $ex;
}
$this->dataStore[$name] = $value;
}
示例8: __set
public function __set($name, $value)
{
try {
parent::__set($name, $value);
if ($name === 'eav_set_id') {
$this->refreshEavAttributes();
}
} catch (CException $ex) {
if ($this->setEavAttribute($name, $value) === false) {
throw $ex;
}
}
}
示例9: __set
public function __set($name, $val)
{
try {
return parent::__set($name, $val);
} catch (CException $e) {
$method_name = StringHelper::underscoreToCamelcase($name);
$method_name = 'set' . ucfirst($method_name);
if (method_exists($this, $method_name)) {
return $this->{$method_name}($val);
} else {
throw new CException($e->getMessage());
}
}
}
示例10: __set
/**
* If an array of arrays is passed for a HAS_MANY relation attribute, will create appropriate objects
* to assign to the attribute. Sets up the afterSave method to saves these objects if they have validated.
*
* NOTE once a property is set, this magic method will not be called by php for setting it again, unless the property
* is unset first.
*
* @param string $name
* @param mixed $value
* @throws Exception
* @return mixed|void
*/
public function __set($name, $value)
{
// Only perform this override if turned on for the given model
if ($this->auto_update_relations && is_array($value) && count($value) && isset($this->getMetaData()->relations[$name])) {
$rel = $this->getMetaData()->relations[$name];
$cls = get_class($rel);
if ($cls == self::HAS_MANY || $cls == self::MANY_MANY) {
$rel_cls = $rel->className;
$pk_attr = $rel_cls::model()->getMetaData()->tableSchema->primaryKey;
// not supporting composite primary keys at this point
if (is_string($pk_attr)) {
$m_set = array();
foreach ($value as $v) {
if (is_array($v)) {
// looks like a list of attribute values, try to find or instantiate the classes
if (array_key_exists($pk_attr, $v) && isset($v[$pk_attr])) {
$m = $rel_cls::model()->findByPk($v[$pk_attr]);
} else {
$m = new $rel_cls();
}
$m->attributes = array_merge($this->getRelationsDefaults($name), $v);
// set foreign key on the related object
$m->{$rel->foreignKey} = $this->getPrimaryKey();
} elseif (is_object($v)) {
$m = $v;
} else {
// try to find the instance
if (!($m = $rel_cls::model()->findByPk($v))) {
throw new Exception("Unable to understand value " . print_r($v, true) . " for {$name}");
}
}
$m_set[] = $m;
}
// reset the value for it to be set by parent method
$value = $m_set;
}
}
}
parent::__set($name, $value);
}
示例11: __set
public function __set($name, $value)
{
$this->initRelation();
switch (true) {
case Helper::isLastString($name, 'PageSize'):
$name = substr_replace($name, '', -8);
$this->__pageSize[$name] = $value;
break;
case Helper::isLastString($name, 'Insert'):
$name = substr_replace($name, '', -6);
if (isset($this->__relations[$name])) {
$this->__relInsert[$name] = $value;
}
break;
case Helper::isLastString($name, 'Update'):
$name = substr_replace($name, '', -6);
if (isset($this->__relations[$name])) {
$this->__relUpdate[$name] = $value;
}
break;
case Helper::isLastString($name, 'Delete'):
$name = substr_replace($name, '', -6);
if (isset($this->__relations[$name])) {
$this->__relDelete[$name] = $value;
}
break;
case isset($this->__relations[$name]):
$this->__relations[$name] = $value;
break;
default:
try {
parent::__set($name, $value);
} catch (Exception $e) {
$this->__tempVar[$name] = $value;
}
break;
}
}
示例12: __set
public function __set($name, $value)
{
if ($name === 'attributes') {
foreach ($value as $key => $val) {
if (strpos($key, '.') !== false) {
$parts = explode('.', $key);
$relation = $this->getActiveRelation($parts[0]);
$className = $relation->className;
$model = new $className();
if ($model->hasAttribute($parts[1]) || $model->hasProperty($parts[1])) {
$this->Search[$parts[0]][$parts[1]] = $val;
}
}
}
}
parent::__set($name, $value);
}
示例13: __set
public function __set($name, $value)
{
$flags = $this->cachedFlags();
if (strncasecmp($name, $this->namePrefix, 2) === 0) {
$name = substr(strtolower($name), strlen($this->namePrefix));
if (isset($flags[$name])) {
$this->setFlag($flags[$name], $value);
}
} else {
parent::__set($name, $value);
}
}
示例14: __set
public function __set($name, $value)
{
$isSerialized = $this->isSerializedAttr($name);
if ($isSerialized) {
$this->getData()->{$name} = $value;
} else {
parent::__set($name, $value);
}
}
示例15: __set
/**
* @see CActiveRecord::__set()
*/
public function __set($name, $value)
{
if ($this->getAttribute($name) == $value) {
return;
}
parent::__set($name, $value);
if (!$this->getIsNewRecord() && $this->hasAttribute($name)) {
$this->_dirtykeys[] = $name;
$this->_isdirty = true;
}
}