]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-15808 Applying Andrei's patch
authornicolasconnault <nicolasconnault>
Thu, 24 Jul 2008 12:21:19 +0000 (12:21 +0000)
committernicolasconnault <nicolasconnault>
Thu, 24 Jul 2008 12:21:19 +0000 (12:21 +0000)
lib/dml/moodle_database.php
lib/simpletest/fixtures/gradetest.php

index 5abdadccd09750565f1c42ed78bf49f1d7647c70..89a34ead5bb0b6f317c36bd792355f75a778c7a0 100644 (file)
@@ -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()
index a7fed55103988a7a02e4a9417e0c9698bc705872..43e3422b6c1ca622a08ccef80e92d460b9e4fe1b 100644 (file)
@@ -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_");
         }