Set and update a single object attribute in the database
@param string $name Attribute name
@param string $value Attribute value
@param \PDO $db Database connection to use, default to master resource
@return boolean
557562
public function updateAttribute ($name, $value, &$db = FALSE)
	{
		
		// Get database master for write

		if ($db === FALSE)
		{
			$db	=& $this->getDbMaster ();
		}
		
		// Changelog
		
		$old = FALSE;
		
		if ($this->changelog ('update'))
		{
			$old = static::_Read ($this->iget (static::$pk), $db);
		}
		
		$this->iset ($name, $value);

        // Prepare query

        $exclude = [];

        $query = $db->prepare ('
		UPDATE `' . static::$dbTable . '`
		SET ' . $name . ' = ' . $this->transformValue ($name, $value, $exclude) . '
		WHERE ' . static::$pk . ' = :pk
		');

        // Bind values

        if (!in_array($name, $exclude)) {
            $query->bindValue (':' . $name,	$this->iget ($name));
        }
        $query->bindValue (':pk',	$this->iget (static::$pk));

        // Execute

		if (!$query->execute ())
		{
			return FALSE;
		}
		
		// Changelog
		
		if ($old)
		{
			
			// Only update attribute thats changed
			
			$exclude = $this->toArray ();
			unset ($exclude[$name]);
			
			$log =& $this->getResource ('changelog');
			$log->hookTransactions ($db);
			$log::_Log ('update', $old, $this, array_keys ($exclude));
			
		}
		
		// Return TRUE
		
		return TRUE;
		
	}
254929
public function withAttribute(string $name, $value = null)
    {
        $this->attributes[$name] = $value;

        return $this;
    }
1151512
public function setAttr($name, $value = null)
    {
        $wrapper = $this->getWrapper();
        
        // set attribute.
        $wrapper[$name] = $value;

        return $this->setWrapper($wrapper);
    }
226937
protected function setDatabase($name) {
        if (isset($name) && !is_string($name)) throw new IllegalTypeException('Illegal type of parameter $name: '.gettype($name));
        if (!strlen($name))
            $name = null;

        $this->database = $name;
        return $this;
    }
622027
protected function setAttrVal($name, $value)
    {
        // 数据保护，启用数据独立的模型，不允许重新加载数据
        if ($this->isInstanceApart && $this->isLoaded()) {
            $pk = $this->getPk();
            if((is_array($pk) && array_key_exists($name, $pk) && $this->getPkv()[$name] != $value)
                || (is_scalar($pk) && strtolower($name) == strtolower($pk) && $this->getPkv() != $value)) {
                $msg = "The primarykey '{$name}' is readonly, if you are going to change it in any case, "
                    . "you must new another instance of " . get_class($this) . " or set the 'isInstanceApart' property as false.";
                throw new Exception($msg);
            }
        }

        // 表字段有对应已定义模型类属性
        if($this->columnMap && array_key_exists($name, $this->columnMap)) {
            $attr = $this->columnMap[$name];
            $setter = 'set' . $attr;

            if(method_exists($this, $setter)) {
                $this->$setter($value);
            } else {
                $this->$attr = $value;
            }

            return $this;
        } else if (property_exists($this, $name)) {
            // 重载元素时存在同名已声明私有属性名无映射不允许重载赋值
            throw new \InvalidArgumentException('access non public property on __get():' . get_class($this) . '::' . $name);
        } else {
            $this->attrs[$name] = $value;
        }

        return $this;
    }
444728
public function setAttribute(int $attr, $value): bool
    {
        if ($attr === \PDO::ATTR_EMULATE_PREPARES) {
            if ($value !== false) {
                throw new \Exception(
                    'EasyDB does not allow the use of emulated prepared statements, ' .
                    'which would be a security downgrade.'
                );
            }
        }
        if ($attr === \PDO::ATTR_ERRMODE) {
            if ($value !== \PDO::ERRMODE_EXCEPTION) {
                throw new \Exception(
                    'EasyDB only allows the safest-by-default error mode (exceptions).'
                );
            }
        }
        return $this->pdo->setAttribute($attr, $value);
    }
454623
public function SetPreference($Name, $Value = '', $SaveToDatabase = TRUE) {
      if (!is_array($Name))
         $Name = array($Name => $Value);

      foreach($Name as $Key => $Val) {
         $this->_Preferences[$Key] = $Val;
      }

      if ($SaveToDatabase && $this->UserID > 0) {
         $UserModel = Gdn::UserModel();
         $UserModel->SavePreference($this->UserID, $Name);
      }
   }
346352
public static function set(&$object, $name, $value)
    {
        $names = explode('.', $name);
        $lastName = array_pop($names);
        $data = &$object;
        foreach ($names as $nameItem)
        {
            if(is_array($data))
            {
                if (!isset($data[$nameItem]))
                {
                    $data[$nameItem] = [];
                }
                $data = &$data[$nameItem];
            }
            else if(is_object($data))
            {
                if (!isset($data->$nameItem))
                {
                    $data->$nameItem = new stdClass;
                }
                $data = &$data->$nameItem;
            }
        }
        if(is_array($data))
        {
            $data[$lastName] = $value;
        }
        else if(is_object($data))
        {
            $data->$lastName = $value;
        }
    }
175946
protected function _set($name, $value)
    {
        $this->_data[$name] = $value;

        // Do not reload / save here:
        // 1: other changes might follow,
        // 2: it might not be used,
        // 3: e.g. database saves may change other data.
        $this->invalidateCache();

        return $this;
    }
1042045
public function set($name, $value)
    {
        $name = $this->parseName($name);
        ObjectArrayHelper::set($this->data, $name, $value);
        $this->isChanged = true;
    }
759626
public function setAttribute($name, $value)
    {
        if (is_numeric($value)) {
            $value = (string) $value;
        }

        if (!is_string($value) && $value !== null) {
            throw new InvalidArgumentException(sprintf('%s expects parameter 2 to be string or null, %s given', __METHOD__, (is_object($value) ? get_class($value) : gettype($value))));
        }

        $this->node->setAttribute($name, $value);

        return $this;
    }
430852
public function attr($name, $value = null)
    {
        $attrs = (array) $this->getAttribute('attribs');

        if ($value === null) {
            return isset($attrs[$name]) ? $attrs[$name] : null;
        }

        $attrs[$name] = $value;

        $this->setAttribute('attribs', $attrs);

        return $this;
    }
674680
public function set($name, $value)
    {
        if (!$this->isLocked()) {
            $_SESSION[$this->publicStorage]['store'][$this->_namespaceName][$name] = $value;
            return true;
        }
        return false;
    }
414771
public static function set($name, $value)
    {
        $model = self::find()->where([self::getNameAttribute() => $name])->one();
    
        if ($model) {
            return (bool) $model->updateAttributes([
                self::getValueAttribute() => $value,
            ]);
        }
    
        $model = new self();
        $model->value = $value;
        $model->name = $name;
        return $model->save();
    }
1340091
public function attr($name, $value = null){
        if(is_null($value)){
            return $this->getAttributeValue($name);
        }else{
            return $this->setAttribute($name, $value);
        }
    }
737415
public function setAttribute($name, $value)
	{
		$this->model->$name = $value;
		if (!in_array($name, $this->changedAttributes)) {
			$this->changedAttributes[] = $name;
		}
	}
299766
public function attr($name, $value = null)
    {
        if (func_num_args() < 2) {
            return @$this->attributes[$name];
        } else {
            if (is_null($value)) {
                unset($this->attributes[$name]);
            } else {
                $this->attributes[$name] = $value;
            }
            return $this;
        }
    }