openrat-cms

OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs | README

commit 26364c8b7b3742bb242a6fc63ee044448a65818b
parent 4b5cf966691aea9021b5953a12e8373cdc79a8bb
Author: Jan Dankert <develop@jandankert.de>
Date:   Fri, 23 Oct 2020 11:28:46 +0200

Fix: Getting the PDO driver from the DSN.

Diffstat:
Mmodules/database/DbVersion.class.php | 23+++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/modules/database/DbVersion.class.php b/modules/database/DbVersion.class.php @@ -29,20 +29,14 @@ abstract class DbVersion $this->db = $db; switch ($db->conf['type']) { - case 'mysql': - case 'mysqli': - $this->dbmsType = DbVersion::TYPE_MYSQL; - break; - case 'postgresql': - $this->dbmsType = DbVersion::TYPE_POSTGRES; - break; - case 'sqlite': - case 'sqlite3': - $this->dbmsType = DbVersion::TYPE_SQLITE; - break; case 'pdo': - $dsnParts = explode(':', $db->conf['dsn']); - switch ($dsnParts[0]) { + if ( $db->conf['dsn'] ) { + $dsnParts = explode(':', $db->conf['dsn']); + $driver = $dsnParts[0]; + }else { + $driver = $db['driver']; + } + switch ($driver) { case 'mysql': $this->dbmsType = DbVersion::TYPE_MYSQL; break; @@ -53,10 +47,11 @@ abstract class DbVersion $this->dbmsType = DbVersion::TYPE_SQLITE; break; default: - throw new \LogicException('Unknown DBMS in PDO-DSN: ' . $dsnParts[0]); + throw new \LogicException('Unknown PDO driver: ' . $driver); } break; default: + // for now we are only supporting PDO. throw new \LogicException('Unknown DBMS type: ' . $db->conf['type']); }