<?php
require 'pdo_config.php';
$dsn = "{$dbType}:host={$host};dbName={$dbName}}";// 创建数据源
try{
$pdo = new PDO ($dsn,$userName,$password);
$sql = "update student set grade=80 where id=7";
$num = $pdo->exec($sql);//返回受影响的记录数量
if($num>0){
print '成功添加';
}else{
print '不成功';
}
}
catch(PDOexception $e){
die('操作失败'.$e->getMessage());
}Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号