PDO : Select using a prepared statement returns column name

一笑奈何 提交于 2019-12-01 21:38:08
Galen

No you can't bind column names or table names.

Here's more info Escaping column names in PDO statements

A prepared statement can only replace value in the statement not field nor column name, this is because prepared statement are kind of precompiled and optimized in function of the whole statement except the value.

so this is possible:

SELECT id FROM users WHERE name=?

but not this:

SELECT ? FROM users WHERE name='john'
SELECT id FROM ? WHERE name='john'
SELECT id FROM users WHERE ?='john'
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!