Commit 9536b18d authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review
Browse files

Merge "Bug 1698978: get_records_*_assoc functions fail on one field"

parents 33fd2a04 be550b4e
......@@ -556,6 +556,20 @@ function recordset_to_array(ADORecordSet $rs) {
* @access private
*/
function recordset_to_assoc(ADORecordSet $rs) {
if ($rs->NumCols() < 2) {
$colname = $rs->FetchField(0)->name;
$records = $rs->GetAll();
if (empty($records)) {
return false;
}
$objects = [];
foreach ($records as $val) {
$objects[(string) $val[$colname]] = (object) $val;
}
return $objects;
}
if ($rs && $rs->RecordCount() > 0) {
// First of all, we are going to get the name of the first column
// to introduce it back after transforming the recordset to assoc array
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment