InSys / pdo-extended

PDO extended class
https://intsystem.org/coding/delaem-pdo-udobnym/
GNU General Public License v2.0
4 stars 2 forks source link

Fatal error under PHP 8.0 #1

Open s22-tech opened 1 year ago

s22-tech commented 1 year ago

Trying to use this class, I get this error:

PHP Fatal error: Declaration of PDOExtended::query($statement, $params = []) must be compatible with PDO::query(string $query, ?int $fetchMode = null, mixed ...$fetchModeArgs) in class.pdo.extended.php line 236

Any idea how to fix this?

dastanaron commented 1 year ago
  1. Do not use this extension in php 8.0. Latest update on Jun 26, 2016
  2. Fork this repository and fix it self
  3. Create pull-request with fix
  4. Do not use php 8.0
s22-tech commented 1 year ago

I found it, and it's actually a pretty simple fix. Line 236 needs to be changed to: public function query($statement, ...$params) { That's it! It now works under PHP 8.0.

Also, keep in mind that you have to call PDOExtended, instead of just PDO, when creating your $pdo instance, e.g. $pdo = new \PDOExtended($dsn, $db_username, $db_password, $options);.

That threw me for awhile until I finally saw my mistake. 😕