update 更新
优质
小牛编辑
133浏览
2023-12-01
update
修改表数据
update($table, $data, $where)table [string]
表名.
data [array]
修改的数据.
where (optional) [array]
WHERE 条件.[可选]
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 statementecho $data->rowCount();// Read more: http://php.net/manual/en/class.pdostatement.php