Index: dml/moodle_database.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/dml/moodle_database.php,v retrieving revision 1.38 diff -u -r1.38 moodle_database.php --- dml/moodle_database.php 21 Jul 2008 07:18:58 -0000 1.38 +++ dml/moodle_database.php 24 Jul 2008 09:42:50 -0000 @@ -86,6 +86,19 @@ } /** + * 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() * @return string db family name (mysql, postgres, mssql, oracle, etc.) Index: simpletest/fixtures/gradetest.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/simpletest/fixtures/gradetest.php,v retrieving revision 1.39 diff -u -r1.39 gradetest.php --- simpletest/fixtures/gradetest.php 22 Jun 2008 16:51:55 -0000 1.39 +++ simpletest/fixtures/gradetest.php 24 Jul 2008 09:41:50 -0000 @@ -87,7 +87,7 @@ 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_"); }