<?php require 'pdo_config.php'; $dsn = "{$dbType}:host={$host};dbName={$dbName}}";// 創(chuàng)建數(shù)據(jù)源 try{ $pdo = new PDO ($dsn,$userName,$password); $sql = "update student set grade=80 where id=7"; $num = $pdo->exec($sql);//返回受影響的記錄數(shù)量 if($num>0){ print '成功添加'; }else{ print '不成功'; } } catch(PDOexception $e){ die('操作失敗'.$e->getMessage()); }