I am trying to make a simple request on my database, whoever, my attempts with binding something to the query doesn't work. I tried both codes and none seems to work
$query = $this->prepare("SELECT * FROM :table");
$query->bindParam(":table", $this->table);
$query->execute();
return $query->fetchAll();
$query = $this->prepare("SELECT * FROM :table");
$query->execute(array(":table" => $this->table));
return $query->fetchAll();
However, When I try to just concatenate it, it works just fine
$query = $this->prepare("SELECT * FROM " . $this->table);
$query->execute();
return $query->fetchAll();
Does anyone know what might be happening? What am I doing wrong? Is that any standard that I'm not aware here? I've done something similar before and it worked fine
OBS: The $this
reffers to this:
class Db extends PDO{}