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()
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_");
}