From 0a505fd383f0a7d45cc9442ef5fcaf9fece3ca54 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 6 Feb 2011 01:18:45 +0100 Subject: [PATCH] only load mdb2 when we use the database --- inc/lib_base.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/inc/lib_base.php b/inc/lib_base.php index b8bbcb83d1..6819468565 100644 --- a/inc/lib_base.php +++ b/inc/lib_base.php @@ -1,5 +1,4 @@ MDB2_PORTABILITY_ALL, @@ -400,10 +398,14 @@ class OC_DB { 'database' => $CONFIG_DBNAME, ); } - self::$DBConnection=&MDB2::factory($dsn,$options); + self::$DBConnection=MDB2::factory($dsn,$options); + if (PEAR::isError(self::$DBConnection)) { echo('can not connect to database, using '.$CONFIG_DBTYPE.'. ('.self::$DBConnection->getUserInfo().')'); - die(self::$DBConnection->getMessage()); + $error=self::$DBConnection->getMessage(); + error_log("$error"); + error_log(self::$DBConnection->getUserInfo()); + die($error); } self::$DBConnection->setFetchMode(MDB2_FETCHMODE_ASSOC); } @@ -411,6 +413,7 @@ class OC_DB { public static function connectScheme(){ self::connect(); + @oc_require_once('MDB2/Schema.php'); if(!self::$schema){ self::$schema=&MDB2_Schema::factory(self::$DBConnection); } @@ -467,7 +470,7 @@ class OC_DB { $cmd=str_replace('`','"',$cmd); } $result=self::$DBConnection->queryAll($cmd); - if (PEAR::isError($result)) { + if (PEAR::isError($result)){ $entry='DB Error: "'.$result->getMessage().'"
'; $entry.='Offending command was: '.$cmd.'
'; die($entry);