Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Declaration of OM\Db::query(string $statement) must be compatible with PDO::query

Tags:

php

php-8

I just installed PHP 8 and I have this error appears? How do I fix it?

Fatal error: Declaration of OM\Db::query(string $statement) must be compatible with PDO::query(string $query, ?int $fetchMode = null, mixed ...$fetchModeArgs) in /home/www/includes/OM/Db.php on line 131

My OM/Db.php

public function query(string $statement) =====> line 131
{
  $statement = $this->autoPrefixTables($statement);

  $args = func_get_args();

  if (count($args) > 1) {
    $DbStatement = call_user_func_array(array($this, 'parent::query'), $args);
  } else {
    $DbStatement = parent::query($statement);
  }

  if ($DbStatement !== false) {
    $DbStatement->setQueryCall('query');
    $DbStatement->setPDO($this);
  }

  return $DbStatement;
}
like image 595
Harry Avatar asked Nov 07 '20 10:11

Harry


People also ask

What is PDO query?

PDO (PHP Data Objects) is an abstraction layer for your database queries and is an awesome alternative to MySQLi, as it supports 12 different database drivers. This is an immense benefit for people and companies that need it.

How do I run a PDO query?

To prepare and execute a single SQL statement that accepts no input parameters, use the PDO::exec or PDO::query method. Use the PDO::exec method to execute a statement that returns no result set. Use the PDO::query method to execute a statement that returns one or more result sets.

What does PDO -> query return?

PDO::query() returns a PDOStatement object, or FALSE on failure.


1 Answers

  1. Remove "doctrine/dbal": "^2.10" from composer.json

  2. Then (and finally) run composer update

like image 132
David Raleche Avatar answered Oct 16 '22 09:10

David Raleche