为什么这个有效
class xyz{
private $_db;
function __construct(){
//database connection
}
function abc($login,$pass,$email){
$l = "login";
$check = $this->_db->prepare("SELECT userid FROM users WHERE login = ?");
$check->execute(array($login));
$res1 = $check->fetch(PDO::FETCH_NUM);
return var_dump($res1);
}
}
如果我将登录的行选择更改为变量,则代码返回 bool false
class xyz{
private $_db;
function __construct(){
//database connection
}
function abc($login,$pass,$email){
$l = "login";
$check = $this->_db->prepare("SELECT userid FROM users WHERE ? = ?");
$check->execute(array($l,$login));<<<<<-----THIS $l FAILS TO WORK
$res1 = $check->fetch(PDO::FETCH_NUM);
return var_dump($res1);
}
}
使用不同的行选择及其值执行 3 个完全相同的查询的最佳方法是什么?