From fd734f6165c6595e7d6529cdbbedf12fa608717a Mon Sep 17 00:00:00 2001 From: martinlanghoff Date: Wed, 7 Sep 2005 06:12:40 +0000 Subject: [PATCH] Merged from MOODLE_15_STABLE - Fix for bug 4011 -- a MySQL specific workaround did not work with database names with hyphens, and broke the whole plugin for other databases. This patch fixes both issues. --- enrol/database/enrol.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/enrol/database/enrol.php b/enrol/database/enrol.php index f04881bc989..1a7df1913ba 100644 --- a/enrol/database/enrol.php +++ b/enrol/database/enrol.php @@ -21,13 +21,14 @@ function get_student_courses(&$user) { /// If the database fails we can at least use this // This is a hack to workaround what seems to be a bug in ADOdb with accessing - // two databases of the same kind ... it seems to get confused when trying to access + // two MySQL databases ... it seems to get confused when trying to access // the first database again, after having accessed the second. // The following hack will make the database explicit which keeps it happy - - if (strpos($CFG->prefix, $CFG->dbname) === false) { - $oldprefix = $CFG->prefix; - $CFG->prefix = "$CFG->dbname.$CFG->prefix"; + if ($CFG->dbtype === 'mysql' && $CFG->enrol_dbtype === 'mysql') { + if (strpos($CFG->prefix, $CFG->dbname) === false) { + $oldprefix = $CFG->prefix; + $CFG->prefix = "`$CFG->dbname`.$CFG->prefix"; + } } // Try to connect to the external database