[英] Can PHP PDO Statements accept the table or column name as parameter?
为什么我不能将表名传递给准备好的PDO语句?
$stmt = $dbh->prepare('SELECT * FROM :table WHERE 1');
if ($stmt->execute(array(':table' => 'users'))) {
var_dump($stmt->fetchAll());
}
有没有其他安全的方法将表名插入到SQL查询中?有了保险箱,我的意思是我不想这么做
$sql = "SELECT * FROM $table WHERE 1"