本文整理汇总了PHP中CModel::__set方法的典型用法代码示例。如果您正苦于以下问题:PHP CModel::__set方法的具体用法?PHP CModel::__set怎么用?PHP CModel::__set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CModel
的用法示例。
在下文中一共展示了CModel::__set方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __set
public function __set($name, $value)
{
if (array_key_exists($name, $this->data)) {
$this->data[$name] = $value;
} else {
parent::__set($name, $value);
}
}
示例2: __set
public function __set($name, $value)
{
if ($this->hasAttribute($name, $value)) {
$this->setAttribute($name, $value);
} else {
parent::__set($name, $value);
}
}
示例3: __set
public function __set($name, $value)
{
if (in_array($name, $this->attributeNames())) {
$this->_attributes[$name] = $value;
} else {
parent::__set($name, $value);
}
}
示例4: __set
/**
* @see CComponent::__set()
* @param string $name
* @param mixed $value
* @return mixed
*/
public function __set($name, $value)
{
if (isset($this->_related[$name]) || array_key_exists($name, $this->relations())) {
return $this->_related[$name] = $value;
}
// This might be a little unperformant actually since Yiis own active record detects
// If an attribute can be set first to ensure speed of accessing local variables...hmmm
try {
return parent::__set($name, $value);
} catch (CException $e) {
return $this->setAttribute($name, $value);
}
}
示例5: __set
public function __set($name, $value)
{
if ($this->setAttribute($name, $value) === false) {
if (isset($this->getMetaData()->relations[$name])) {
$this->_related[$name] = $value;
} else {
parent::__set($name, $value);
}
}
}
示例6: __set
/**
* PHP setter magic method.
*
* @param string $name
* @param mixed $value
*
* @return mixed
*/
public function __set($name, $value)
{
if ($this->setAttribute($name, $value) === false) {
parent::__set($name, $value);
}
}
示例7: __set
/**
* @since v1.0.8
*/
public function __set($name, $value)
{
if ($this->hasEmbeddedDocuments() && isset(self::$_embeddedConfig[get_class($this)][$name])) {
if (is_array($value)) {
// Late creation of embedded documents on first access
if (is_null($this->_embedded->itemAt($name))) {
$docClassName = self::$_embeddedConfig[get_class($this)][$name];
$doc = new $docClassName($this->getScenario());
$doc->setOwner($this);
$this->_embedded->add($name, $doc);
}
return $this->_embedded->itemAt($name)->attributes = $value;
} else {
if ($value instanceof EMongoEmbeddedDocument) {
return $this->_embedded->add($name, $value);
}
}
} else {
parent::__set($name, $value);
}
}
示例8: __set
/**
* PHP setter magic method.
* This method is overridden so that MongoDB document can be accessed like properties.
* @param string property name
* @param mixed property value
*/
public function __set($name, $value)
{
if ($name === 'id') {
$this->_document['_id'] = $value;
} elseif (array_key_exists($name, $this->_document)) {
$this->_document[$name] = $value;
} else {
parent::__set($name, $value);
}
}
示例9: __set
/**
* PHP setter magic method.
* This method is overridden so that Resource Model attributes can be accessed like properties.
* @param string $name property name
* @param mixed $value property value
* @return void
*/
public function __set($name, $value)
{
if ($this->setAttribute($name, $value) === false) {
if (isset($this->_links[$name])) {
$this->_linked[$name] = $value;
} else {
parent::__set($name, $value);
}
}
}
示例10: __set
/**
* Волшебный сеттер
* @param type $name
* @param type $value
*/
public function __set($name, $value)
{
// на случай наличия маппинга поля
$mapping = $this->fieldsMapping();
if (array_key_exists($name, $mapping)) {
$name = $mapping[$name];
}
// сначала проверим какого типа пришло значение
// просто setItemValue() вызываем только в случае
// простых типов данных
if (!is_object($value)) {
if ($this->getDbTable()->getFields()->hasElement($name)) {
$this->getRecord()->setItemValue($name, $value);
if (!array_key_exists($name, $this->getRecord()->getItems())) {
$trace = debug_backtrace();
trigger_error('Неопределенное свойство в __set(): ' . $name . ' в файле ' . $trace[0]['file'] . ' на строке ' . $trace[0]['line'], E_USER_NOTICE);
return null;
}
}
} else {
// пришел объект
// объекты складываем в соответствии с relations()
if (!array_key_exists($name, $this->relations())) {
// обратимся к родительскому методу
parent::__set($name, $value);
return;
}
$relations = $this->relations();
$relation = $relations[$name];
// разрешим не указывать
if (!array_key_exists("storageProperty", $relation)) {
$relation["storageProperty"] = "_" . $name;
}
// определяем, какой тип связи
if ($relation['relationPower'] == RELATION_HAS_ONE) {
// сначала кладем объект в приватное свойство
$private = $relation['storageProperty'];
$this->{$private} = $value;
// теперь в поле кладем id объекта
$field = $relation['storageField'];
$this->getRecord()->setItemValue($field, $value->getId());
}
}
}
示例11: __set
/**
* Sets value of a component property.
* Do not call this method. This is a PHP magic method that we override
* to allow using the following syntax to set a property or attach an event handler
* <pre>
* $this->propertyName=$value;
* $this->eventName=$callback;
* </pre>
* @param string $name the property name or the event name
* @param mixed $value the property value or callback
* @return mixed
* @throws \CException if the property/event is not defined or the property is read only.
* @see __get
*/
public function __set($name, $value)
{
if (array_key_exists($name, $this->_attributes)) {
$this->_attributes[$name] = $value;
} else {
parent::__set($name, $value);
}
}
示例12: __set
public function __set($name, $value)
{
if (isset($this->_attributes[$name])) {
$this->_values[$name] = $value;
} else {
parent::__set($name, $value);
}
}