我一直在努力将我当前的脚本换成 PDO。我已经简化了这个例子的 MySQL 查询,但即使是这个版本,错误仍然存在。
$sql = 'SELECT * FROM :table WHERE lastUpdate > :appDate';
try{
$db = connect();
$stmt = $db->prepare($sql);
$stmt->bindParam(':table', $table);
$stmt->bindParam(':appDate', $appDate);
foreach($tablesToCheck as $table){
$stmt->execute();
$resultset[] = $stmt->fetchAll();
}
} catch(PDOException $e){
print 'Error!: '.$e->getMessage().'<br/>';
}//End try catch
$stmt->errorInfo() 返回:
( [0] => 42000 [1] => 1064 [2] => You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the
right syntax to use near ''GroupName' WHERE lastUpdate > NULL' at line 1 )