mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
Setting some ADOdb variables properly and calling to the new
configure_dbconnection() function to set DB encoding and other preliminar settings.
This commit is contained in:
parent
d086d854a8
commit
73bb7f8db0
1 changed files with 13 additions and 8 deletions
|
@ -110,6 +110,10 @@ global $HTTPSPAGEREQUIRED;
|
|||
|
||||
/// Connect to the database using adodb
|
||||
|
||||
/// Some defines required BEFORE including AdoDB library
|
||||
define ('ADODB_ASSOC_CASE', 0); //Use lowercase fieldnames for ADODB_FETCH_BOTH
|
||||
//(only meaningful for oci8po, it's the default
|
||||
//for other DB drivers so this won't affect them)
|
||||
|
||||
require_once($CFG->libdir .'/adodb/adodb.inc.php'); // Database access functions
|
||||
|
||||
|
@ -149,6 +153,12 @@ global $HTTPSPAGEREQUIRED;
|
|||
die;
|
||||
}
|
||||
|
||||
/// Force fetchmode of records for Execute() and SelectLimit() to BOTH
|
||||
/// (it isn't default in all the DB drivers. With the time we should
|
||||
/// try to migrate to FETCH_ASSOC, possible with some tricks in the
|
||||
/// recordset_to_array() function to maintain the id field properly.
|
||||
$db->SetFetchMode(ADODB_FETCH_BOTH);
|
||||
|
||||
/// Starting here we have a correct DB conection but me must avoid
|
||||
/// to execute any DB transaction until "set names" has been executed
|
||||
/// some lines below!
|
||||
|
@ -180,7 +190,6 @@ global $HTTPSPAGEREQUIRED;
|
|||
|
||||
raise_memory_limit('64M'); // We should never NEED this much but just in case...
|
||||
|
||||
|
||||
/// If $CFG->unicodedb is not set, get it from database or calculate it because we need
|
||||
/// to know it to "set names" properly.
|
||||
/// (this is the only database interaction before "set names")
|
||||
|
@ -194,13 +203,9 @@ global $HTTPSPAGEREQUIRED;
|
|||
}
|
||||
}
|
||||
/// Set the client/server and connection to utf8 if necessary
|
||||
if ($CFG->unicodedb) {
|
||||
if ($db->databaseType == 'mysql') {
|
||||
$db->Execute("SET NAMES 'utf8'");
|
||||
} else if ($db->databaseType == 'postgres7') {
|
||||
$db->Execute("SET NAMES 'utf8'");
|
||||
}
|
||||
}
|
||||
/// and configure some other specific variables for each db
|
||||
configure_dbconnection();
|
||||
|
||||
/// Now that "set names" has been executed it is safe to
|
||||
/// work with the DB, but never before this!
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue