From 8e1cdaedd2d23469a549a897b6f487f8e1631613 Mon Sep 17 00:00:00 2001 From: vorbildunternehmer Date: Wed, 4 Dec 2024 22:36:10 +0100 Subject: [PATCH] feat: bugfix wpdb --- composer.json | 2 +- src/wp_db.php | 10 ++++++---- src/wp_db_light.php | 7 ++++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 91fafae..43724b0 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "vorbild/wpdb-alternative", "description": "Gives you access to main wpdb->functions", - "version": "1.0", + "version": "2.0", "type": "library", "authors": [ { diff --git a/src/wp_db.php b/src/wp_db.php index 43f3215..7de876a 100644 --- a/src/wp_db.php +++ b/src/wp_db.php @@ -1,5 +1,7 @@ PDO::ERRMODE_EXCEPTION, - PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, - PDO::ATTR_EMULATE_PREPARES => false, + \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, + \PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC, + \PDO::ATTR_EMULATE_PREPARES => false, ]; $dsn = "mysql:host=$this->host;dbname=$this->db;charset=utf8"; try { - $pdo = new PDO($dsn, $this->user, $this->pass, $options); + $pdo = new \PDO($dsn, $this->user, $this->pass, $options); } catch (\PDOException $e) { throw new \PDOException($e->getMessage(), (int)$e->getCode()); } diff --git a/src/wp_db_light.php b/src/wp_db_light.php index 18b0836..10fa414 100644 --- a/src/wp_db_light.php +++ b/src/wp_db_light.php @@ -1,5 +1,6 @@ dbName.'.db'; - $pdo = new PDO("sqlite:$databaseFile"); + $pdo = new \PDO("sqlite:$databaseFile"); // Set the error mode to exception - $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); return $pdo; }