I have a Sql class that was working perfectly fine until PHP7. Now, using PHP8, I get the error shown below.
Fatal error: Declaration of DB\Sql::query($query, $parameters = []) must be compatible with PDO::query(string $query, ?int $fetchMode = null, mixed ...$fetchModeArgs) in C:\xampp\page\class\DB\Sql.php on line 15
Nothing has changed in the code!But I really can't understand what's wrong!
My Sql class has a "query" function like this (line 15)
public function query($query, $parameters=array()) {
$statement = $this->conection->prepare($query);
foreach ($parameters as $key => $value) {
$statement->bindValue($key,$value);
}
$statement->execute();
return $statement;
}
The "$this->conection calls this:
private $conection;
public function __construct() {
$this->conection = new PDO("mysql:host=".dbHost.";dbname=".dbDb,dbUsuario,dbSenha);
}
Thanks to anyone who can help
Remove "query" and use "run" instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With