在使用PDO时,数据库连接正常,但是运行这段代码时,页面既不显示结果,也不显示错误。是不是我这边的PDO无法调用其方法?
<?php
/**
PDO连接数据库
*/
include 'pdo_conf.php';
$dsn = "{$dbType}:host={$host};dbName={$userName}";
try{
$pdo = new PDO($dsn,$userName,$password);
// echo '<h3>连接成功</h3>';
$sql = "UPDATE `student` SET `name` = '秦明一' WHERE `student`.`id` = 14;)";
$num = $pdo->exec($sql);
$insertId = $pdo->lastInsertId();
if($num > 0){
print '成功添加了'.$num.'条记录,最新添加记录ID是'.$insertId;
}
}catch (PDOException $e){
die('操作失败'.$e->getMessage());
}include 'pdo_conf.php';
$dsn = "{$dbType}:host={$host};dbName={$userName}";
try{
$pdo = new PDO($dsn,$userName,$password);
// echo '<h3>连接成功</h3>';
$sql = "UPDATE `student` SET `name` = '秦明一' WHERE `student`.`id` = 14;)";
$num = $pdo->exec($sql);
$insertId = $pdo->lastInsertId();
if($num > 0){
print '成功添加了'.$num.'条记录,最新添加记录ID是'.$insertId;
}
}catch (PDOException $e){
die('操作失败'.$e->getMessage());
}