openrat-cms

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

commit 0963f464809c32df128456829155f5cb64489950
parent 4476ceabee5ff656a8c5a09535be012726209faf
Author: Jan Dankert <develop@jandankert.de>
Date:   Sun, 23 Feb 2020 00:16:20 +0100

Refactoring: Namespacing for module 'database'.

Diffstat:
modules/cms-ui/UI.class.php | 2+-
modules/database/DbVersion.class.php | 2--
modules/database/driver/PDODriver.class.php | 12++++++++++--
modules/database/require.php | 11-----------
4 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/modules/cms-ui/UI.class.php b/modules/cms-ui/UI.class.php @@ -9,7 +9,7 @@ use DomainException; use Exception; use util\Http; use \Less_Parser; -use Logger; +use logger\Logger; use LogicException; use ObjectNotFoundException; use util\exception\OpenRatException; diff --git a/modules/database/DbVersion.class.php b/modules/database/DbVersion.class.php @@ -19,8 +19,6 @@ namespace database { define('OR_DB_COLUMN_NOT_NULLABLE',false); - use util\Http; - abstract class DbVersion { private $db; diff --git a/modules/database/driver/PDODriver.class.php b/modules/database/driver/PDODriver.class.php @@ -28,8 +28,10 @@ use PDOStatement; use \RuntimeException; /** - * Datenbank-abhaengige Methoden fuer PDO. - * + * Implementation of all database operations in PDO. + * + * PDO is available since PHP 5.1 and OpenRat CMS forces a newer PHP version than this. So there should be no problem to rely on PDO. + * * @author Jan Dankert */ class PDODriver @@ -50,6 +52,12 @@ class PDODriver function connect( $conf ) { + if ( !defined('PDO::ATTR_DRIVER_NAME') ) { + // This should never happen, because PHP is always bundled with PDO. + // but maybe... some installation could miss the module. + throw new RuntimeException('PDO unavailable'); + } + $url = $conf['dsn' ]; $user = $conf['user' ]; $pw = $conf['password']; diff --git a/modules/database/require.php b/modules/database/require.php @@ -1,12 +1,2 @@ <?php -include( __DIR__ ."/Database.class.php" ); -include( __DIR__. "/Statement.class.php" ); -include( __DIR__ ."/Sql.class.php" ); -include( __DIR__ ."/DbVersion.class.php" ); - -// PDO is available since PHP 5.1 -if (version_compare(PHP_VERSION, '5.1.0', '>')) - include(__DIR__ . "/driver/PDODriver.class.php"); - -?>- \ No newline at end of file