]> git.mjollnir.org Git - moodle.git/commitdiff
Added the configure_dbconnection() function to be executed
authorstronk7 <stronk7>
Sun, 20 Aug 2006 18:21:33 +0000 (18:21 +0000)
committerstronk7 <stronk7>
Sun, 20 Aug 2006 18:21:33 +0000 (18:21 +0000)
after DB conection. Responsible to set a lot of things
(charsets, dbsession variables...)

lib/dmllib.php

index 1801e8b120330986715fd77df3d3c9d5303ec9ce..5cb8f2673ab03e7c79e5f69398d092e51030b121 100644 (file)
@@ -1240,4 +1240,38 @@ function column_type($table, $column) {
     return $rs->MetaType($field->type);
 }
 
+/**
+ * This function, called from setup.php includes all the configuration
+ * needed to properly work agains any DB. It setups connection encoding
+ * and some other variables.
+ */
+function configure_dbconnection() {
+
+    global $CFG, $db;
+
+    switch ($CFG->dbtype) {
+        case 'mysql':
+        /// Set names if needed
+            if ($CFG->unicodedb) {
+                $db->Execute("SET NAMES 'utf8'");
+            }
+        break;
+        case 'postgres7':
+        /// Set names if needed
+            if ($CFG->unicodedb) {
+                $db->Execute("SET NAMES 'utf8'");
+            }
+        break;
+        case 'mssql':
+        /// No need to set charset. It must be specified in the driver conf
+        /// Allow quoted identifiers
+            $db->Execute('SET QUOTED_IDENTIFIER ON');
+        break;
+        case 'oracle':
+        /// No need to set charset. It must be specified by the NLS_LANG env. variable
+        break;
+    }
+}
+
+
 ?>