public function update ($exclude = array (), &$db = FALSE)
	{
		
		// Get database master for write

		if ($db === FALSE)
		{
			$db	=& $this->getDbMaster ();
		}
		
		// Changelog
		
		$old = FALSE;
		
		if ($this->changelog ('update'))
		{
			$old = static::_Read ($this->get (static::$pk), $db);
		}
		
		// Exclude the primary key
		
		$exclude[]	= static::$pk;
		
		// Set value variable

		$values		= NULL;
		
		// Loop through attributes
		
		foreach (static::$attributes as $name => $attribute)
		{
			
			// If we're excluding the attribute then move on

			if (in_array ($name, $exclude))
			{
				continue;
			}
			
			// If the attribute has derefresh enabled the refresh value to default for the update
			
			if (isset ($attribute['deupdate']) && $attribute['deupdate'])
			{
				$this->reset ($name);
			}
			
			// Else if the attribute is not set or is creation only
			
			else if (!$this->attributeIsset ($name) || 
				(isset ($attribute['creation']) && $attribute['creation']))
			{
				
				// Exclude it and move on
				
				$exclude[]	= $name;
				continue;
				
			}
			
			// Add the value
			
			$values	.= ',`' . $name . '` = ' . $this->transformValue ($name, $attribute, $exclude);
			
		}
		
		// Trim the first character (,) from the values
		
		$values		= substr ($values, 1);
		
		// Prepare query
		
		$query = $db->prepare ('
		UPDATE `' . static::$dbTable . '`
		SET ' . $values . '
		WHERE ' . static::$pk . ' = :pk
		');
		
		// Bind attributes
		
		$this->bindAttributes ($query, $exclude);
		
		// Bind pk
		
		$query->bindValue (':pk', $this->iget (static::$pk));
		
		// Execute
		
		if (!$this->executeCreateUpdateQuery ($query))
		{
			return FALSE;
		}
		
		// Changelog
		
		if ($old)
		{
			$log	=& $this->getResource ('changelog');
			$log->hookTransactions ($db);
			$log::_Log ('update', $old, $this);
		}

		// return TRUE

		return TRUE;
		
	}