|
|
get_records..() functions return data double keyed like:
array (
[0] => myuser
[username] => myuser
[1] => plaaah
[password] => plaah
....
Maybe we doing lot of duplicate checks all around Moodle. At least all foreach loops is twice logger that needed.
ADODB_FETCH_MODE is controlling how data is returned ( see http://phplens.com/adodb/reference.varibles.adodb_fetch_mode.html )
Is it ok to set default ADODB_FETCH_MODE to ADODB_FETCH_ASSOC to return only accosiative array without numbered keys. Or will it broke something?
|
|
Description
|
get_records..() functions return data double keyed like:
array (
[0] => myuser
[username] => myuser
[1] => plaaah
[password] => plaah
....
Maybe we doing lot of duplicate checks all around Moodle. At least all foreach loops is twice logger that needed.
ADODB_FETCH_MODE is controlling how data is returned ( see http://phplens.com/adodb/reference.varibles.adodb_fetch_mode.html )
Is it ok to set default ADODB_FETCH_MODE to ADODB_FETCH_ASSOC to return only accosiative array without numbered keys. Or will it broke something? |
Show » |
|
$db->SetFetchMode() is other way to set this setting.
From Martin Dougiamas (martin at moodle.com) Friday, 15 October 2004, 07:51 PM:
It doesn't actually duplicate anything ... try this:
foreach ($USER as $key => $data) { echo <p>$key ... $data</p>; }
And it's not lengthening any foreach loops, because there's no reason to loop through the fields of a record ...
Best to leave it as is, I think.
From Petri Asikainen (paca at sci.fi) Sunday, 17 October 2004, 10:37 PM:
I find this out when I was writing user syncronisation and using code like:
$users = get_records(user, 'auth', 'ldap');
foreach($users as $user) {
$update='';
$count=0;
$numddd = count($user);
foreach ($user as $key => $value) {
$count++;
$update .= $key .' = \''. $value .'\''.\n;
if ($count < $numddd) { $update .= ', '; }
}
echo $update.\n\n\n;
}
Every update_record and insert_record (by using getInsertSQL) have to use loops handle data. But I havent tested is there any performance differences or not.