Why this one works
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);
}
}
And if i change the row selection for login to the variable the code return 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);
}
}
What is the best way to do 3 exactly same queries with different row selections and their values?