mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
MDL-50307 auth_db: Stop using AS to prevent error with some drivers
This commit is contained in:
parent
c8bde450a1
commit
78a713685d
@ -110,7 +110,7 @@ class auth_plugin_db extends auth_plugin_base {
|
||||
|
||||
$authdb = $this->db_init();
|
||||
|
||||
$rs = $authdb->Execute("SELECT {$this->config->fieldpass} AS userpass
|
||||
$rs = $authdb->Execute("SELECT {$this->config->fieldpass}
|
||||
FROM {$this->config->table}
|
||||
WHERE {$this->config->fielduser} = '".$this->ext_addslashes($extusername)."'");
|
||||
if (!$rs) {
|
||||
@ -125,7 +125,7 @@ class auth_plugin_db extends auth_plugin_base {
|
||||
}
|
||||
|
||||
$fields = array_change_key_case($rs->fields, CASE_LOWER);
|
||||
$fromdb = $fields['userpass'];
|
||||
$fromdb = $fields[strtolower($this->config->fieldpass)];
|
||||
$rs->Close();
|
||||
$authdb->Close();
|
||||
|
||||
@ -217,18 +217,21 @@ class auth_plugin_db extends auth_plugin_base {
|
||||
if ($selectfields) {
|
||||
$select = array();
|
||||
foreach ($selectfields as $localname=>$externalname) {
|
||||
$select[] = "$externalname AS $localname";
|
||||
$select[] = "$externalname";
|
||||
}
|
||||
$select = implode(', ', $select);
|
||||
$sql = "SELECT $select
|
||||
FROM {$this->config->table}
|
||||
WHERE {$this->config->fielduser} = '".$this->ext_addslashes($extusername)."'";
|
||||
|
||||
if ($rs = $authdb->Execute($sql)) {
|
||||
if (!$rs->EOF) {
|
||||
$fields_obj = $rs->FetchObj();
|
||||
$fields_obj = (object)array_change_key_case((array)$fields_obj , CASE_LOWER);
|
||||
foreach ($selectfields as $localname=>$externalname) {
|
||||
$result[$localname] = core_text::convert($fields_obj->{strtolower($localname)}, $this->config->extencoding, 'utf-8');
|
||||
$fields = $rs->FetchRow();
|
||||
// Convert the associative array to an array of its values so we don't have to worry about the case of its keys.
|
||||
$fields = array_values($fields);
|
||||
foreach (array_keys($selectfields) as $index => $localname) {
|
||||
$value = $fields[$index];
|
||||
$result[$localname] = core_text::convert($value, $this->config->extencoding, 'utf-8');
|
||||
}
|
||||
}
|
||||
$rs->Close();
|
||||
@ -487,15 +490,15 @@ class auth_plugin_db extends auth_plugin_base {
|
||||
$authdb = $this->db_init();
|
||||
|
||||
// Fetch userlist.
|
||||
$rs = $authdb->Execute("SELECT {$this->config->fielduser} AS username
|
||||
$rs = $authdb->Execute("SELECT {$this->config->fielduser}
|
||||
FROM {$this->config->table} ");
|
||||
|
||||
if (!$rs) {
|
||||
print_error('auth_dbcantconnect','auth_db');
|
||||
} else if (!$rs->EOF) {
|
||||
while ($rec = $rs->FetchRow()) {
|
||||
$rec = (object)array_change_key_case((array)$rec , CASE_LOWER);
|
||||
array_push($result, $rec->username);
|
||||
$rec = array_change_key_case((array)$rec, CASE_LOWER);
|
||||
array_push($result, $rec[strtolower($this->config->fielduser)]);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user