db_update()
db_update($table, $cond, $update, $d = NULL)
【功能】
更新记录,成功返回受影响的行数,失败返回 FALSE。
【参数】
$table:表名
$cond:条件
$update: 更新的数据
$d:$db 实例
【$cond】
条件数组的格式:
// 单个条件:
array("gid"=>1)
// 多条:
array("gid"=>1, "uid"=>3)
// 大于
array("create_date"=>array(">"=>100))
// 小于
array("create_date"=>array("<"=>1000))
// LIKE
array("subject"=>array("LIKE"=>"关键字"))
// 组合:
array("gid"=>1, "create_date"=>array(">"=>100, "<"=>1000))
【用例】
<?php
$conf = include "./conf.php";
include "./xiunophp/xiunophp.php";
// 将 uid=123 所在的行的 username 字段值更新为 Mike
$r = db_update("user", array("uid"=>123), array("username"=>"Mike"));
if($r === FALSE) {
echo $errstr;
} else {
echo "更新成功";
}
?>