例子:
<?php //构造PDO连接 $dbh = "mysql:host=localhost;dbname=test"; $db = new PDO($dbh, 'root', 'root123'); $db->query("set character set 'gbk'"); //更新数据 $sql = "UPDATE user SET email='xiaochen@163.com' WHERE username='小陈'"; $count = $db->exec($sql); echo '更新 ',$count,' 条数据记录!'; $db = null; ?>