global $CFG;
- // 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
- // the first database again, after having accessed the second.
- // The following hack will make the database explicit which keeps it happy
- // This seems to broke postgesql so ..
-
- $prefix = $CFG->prefix.''; // Remember it. The '' is to prevent PHP5 reference.. see bug 3223
-
- if ($CFG->dbtype != 'postgres7') {
- $CFG->prefix = $CFG->dbname.$CFG->prefix;
- }
-
- // Connect to the external database
+ // Connect to the external database (forcing new connection)
$authdb = &ADONewConnection($this->config->type);
- $authdb->PConnect($this->config->host, $this->config->user, $this->config->pass, $this->config->name);
+ $authdb->Connect($this->config->host, $this->config->user, $this->config->pass, $this->config->name, true);
$authdb->SetFetchMode(ADODB_FETCH_ASSOC);
if ($this->config->passtype === 'internal') {
AND {$this->config->fieldpass} = '$password' ");
$authdb->Close();
- $CFG->prefix = $prefix;
-
if (!$rs) {
print_error('auth_dbcantconnect','auth');
return false;
global $CFG;
- ADOLoadCode($this->config->type);
- $authdb = &ADONewConnection();
- $authdb->PConnect($this->config->host, $this->config->user, $this->config->pass, $this->config->name);
+ // Connect to the external database (forcing new connection)
+ $authdb = &ADONewConnection($this->config->type);
+ $authdb->Connect($this->config->host, $this->config->user, $this->config->pass, $this->config->name, true);
$authdb->SetFetchMode(ADODB_FETCH_ASSOC);
$fields = array("firstname", "lastname", "email", "phone1", "phone2",
}
function user_exists ($username) {
- $authdb = &ADONewConnection($this->config->type);
- $authdb->PConnect($this->config->host, $this->config->user, $this->config->pass, $this->config->name);
+
+ // Connect to the external database (forcing new connection)
+ $authdb = &ADONewConnection($this->config->type);
+ $authdb->Connect($this->config->host, $this->config->user, $this->config->pass, $this->config->name, true);
$authdb->SetFetchMode(ADODB_FETCH_ASSOC);
$rs = $authdb->Execute("SELECT * FROM {$this->config->table}
function get_userlist() {
- // Connect to the external database
- $authdb = &ADONewConnection($this->config->type);
- $authdb->PConnect($this->config->host,$this->config->user,$this->config->pass,$this->config->name);
+
+ // Connect to the external database (forcing new connection)
+ $authdb = &ADONewConnection($this->config->type);
+ $authdb->Connect($this->config->host, $this->config->user, $this->config->pass, $this->config->name, true);
$authdb->SetFetchMode(ADODB_FETCH_ASSOC);
// fetch userlist
function enrol_connect() {
global $CFG;
- // This is a hack to workaround what seems to be a bug in ADOdb with accessing
- // 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 ($CFG->dbtype === 'mysql' && $CFG->enrol_dbtype === 'mysql') {
- if (strpos($CFG->prefix, $CFG->dbname) === false) {
- $CFG->prefix_old = $CFG->prefix;
- $CFG->prefix = "`$CFG->dbname`.$CFG->prefix";
- }
- }
-
- // Try to connect to the external database
+ // Try to connect to the external database (forcing new connection)
$enroldb = &ADONewConnection($CFG->enrol_dbtype);
- if ($enroldb->PConnect($CFG->enrol_dbhost,$CFG->enrol_dbuser,$CFG->enrol_dbpass,$CFG->enrol_dbname)) {
+ if ($enroldb->Connect($CFG->enrol_dbhost, $CFG->enrol_dbuser, $CFG->enrol_dbpass, $CFG->enrol_dbname, true)) {
$enroldb->SetFetchMode(ADODB_FETCH_ASSOC); ///Set Assoc mode always after DB connection
return $enroldb;
} else {
- // do a bit of cleanup, and lot the problem
- if (!empty($CFG->prefix_old)) {
- $CFG->prefix =$CFG->prefix_old; // Restore it just in case
- unset($CFG->prefix_old);
- }
trigger_error("Error connecting to enrolment DB backend with: "
. "$CFG->enrol_dbhost,$CFG->enrol_dbuser,$CFG->enrol_dbpass,$CFG->enrol_dbname");
return false;
global $CFG;
$enroldb->Close();
-
- // Cleanup the mysql
- // hack
- if (!empty($CFG->prefix_old)) {
- $CFG->prefix =$CFG->prefix_old; // Restore it just in case
- unset($CFG->prefix_old);
- }
}
/**