Get Started

Upgrade

Where Syntax

Query

Aggregation

Fetch

Transaction

Management

Advanced

Raw object

PDO object

Debug

Information

version: 2.1.12

update

Modify data from the table.

update($table, $data, $where)
Return: [PDOStatement] The PDOStatement object.
Most of the features are like insert(), they support array serialization and type auto-detection. Additionally you can use [+], [-], [*] and [/] for mathematical operation.
class Foo {
	var $bar = "cat";

	public function __wakeup()
	{
		$this->bar = "dog";
	}
}

$object_data = new Foo();

$fp = fopen($_FILES[ "file" ][ "tmp_name" ], "rb");

$database->update("account", [
	"type" => "user",

	// All age plus one.
	"age[+]" => 1,

	// All levels subtract 5.
	"level[-]" => 5,

	// All scores multiplied by 2.
	"score[*]" => 2,

	// Array value
	"lang" => ["en", "fr", "jp", "cn"],

	// Array value encoded as JSON.
	"lang [JSON]" => ["en", "fr", "jp", "cn"],

	// Boolean value.
	"is_locked" => true,

	// Object value.
	"object_data" => $object_data,

	// Large Objects (LOBs).
	"image" => $fp
], [
	"user_id[<]" => 1000
]);

// The returned object of update() is PDOStatement, so you can use its methods to get more information. 
$data = $database->update("account", [
	"age[+]" => 1
], [
	"user_id[>]" => 100
]);

// Returns the number of rows affected by the last SQL statement.
echo $data->rowCount();

// Read more: http://php.net/manual/en/class.pdostatement.php