Get Started

Medoo 1.4

Where Syntax

Query

Fetch

Transaction

Advanced

PDO object

Debug

Information

version: 1.4.5

update

Modify data in table

update($table, $data, $where)
Return: [PDOStatement] The PDOStatement object.
Most of feature are like insert(), it supports 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 level subtract 5
	"level[-]" => 5,

	// All score 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,

	// You can also assign # for using SQL functions
	"#uid" => "UUID()"
], [
	"user_id[<]" => 1000
]);

// The return 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