From d086d854a8efd4917ede576ec2abd01d19df7248 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Sun, 20 Aug 2006 18:21:33 +0000 Subject: [PATCH] Added the configure_dbconnection() function to be executed after DB conection. Responsible to set a lot of things (charsets, dbsession variables...) --- lib/dmllib.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/lib/dmllib.php b/lib/dmllib.php index 1801e8b120..5cb8f2673a 100644 --- a/lib/dmllib.php +++ b/lib/dmllib.php @@ -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; + } +} + + ?> -- 2.39.5