From: nicolasconnault Date: Thu, 24 Jul 2008 12:21:19 +0000 (+0000) Subject: MDL-15808 Applying Andrei's patch X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=9fed64fa198057e721b0550ee71b6f68f54aa395;p=moodle.git MDL-15808 Applying Andrei's patch --- diff --git a/lib/dml/moodle_database.php b/lib/dml/moodle_database.php index 5abdadccd0..89a34ead5b 100644 --- a/lib/dml/moodle_database.php +++ b/lib/dml/moodle_database.php @@ -85,6 +85,19 @@ abstract class moodle_database { return $this->prefix; } + /** + * Loads and returns a driver instance with the specified type and library. + * @param string $type database type of the driver (mysql, postgres7, mssql, etc) + * @param string $library database library of the driver (adodb, pdo, etc) + * @return moodle_database driver object + */ + public static function get_driver($type, $library = 'adodb') { + global $CFG; + $classname = $type . '_' . $library . '_moodle_database'; + require_once ("$CFG->libdir/dml/$classname.php"); + return new $classname (); + } + /** * Returns database family type - describes SQL dialect * Note: can be used before connect() diff --git a/lib/simpletest/fixtures/gradetest.php b/lib/simpletest/fixtures/gradetest.php index a7fed55103..43e3422b6c 100644 --- a/lib/simpletest/fixtures/gradetest.php +++ b/lib/simpletest/fixtures/gradetest.php @@ -87,7 +87,7 @@ class grade_test extends UnitTestCase { if (is_null(grade_test::$db)) { $this->realdb = $DB; - grade_test::$db = new mysqli_adodb_moodle_database(); + grade_test::$db = moodle_database::get_driver($CFG->dbtype, $CFG->dblibrary); grade_test::$db->connect($CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->dbpersist, "mdl_unittest_"); }