Witam,
dlaczego otrzymuję błąd składniowy i jak go naprawić?
class Query extends Database {
protected $from;
public function selectAll($table) {
$get = $this->dbCatch->prepare("SELECT * FROM :table");
$get->bindValue(":table", $table, PDO::PARAM_STR);
if (!$get->execute()) {
print_r ($get->errorInfo());
}
return $get;
}
}
$q = new Query;
$q->selectAll('codes');
var_dump($q->selectAll('codes'));
Array ( [0] => 42000 [1] => 1064 [2] => You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''codes'' at line 1 ) Array ( [0] => 42000 [1] => 1064 [2] => You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''codes'' at line 1 ) object(PDOStatement)#5 (1) { ["queryString"]=> string(20) "SELECT * FROM :table" }