From 660744727531f129265abe7da32ac00c501bdd42 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Mon, 28 Jul 2008 22:22:22 +0000 Subject: [PATCH] Implement proper keys for adodb and pdo recordset iterators. MDL-15798 --- lib/dml/adodb_moodle_recordset.php | 3 ++- lib/dml/pdo_moodle_recordset.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/dml/adodb_moodle_recordset.php b/lib/dml/adodb_moodle_recordset.php index a9776957cf..0b325ea734 100644 --- a/lib/dml/adodb_moodle_recordset.php +++ b/lib/dml/adodb_moodle_recordset.php @@ -19,7 +19,8 @@ class adodb_moodle_recordset extends moodle_recordset { } public function key() { - return $this->rs->_currentRow; + /// return first column value as key + return reset($this->rs->fields); } public function next() { diff --git a/lib/dml/pdo_moodle_recordset.php b/lib/dml/pdo_moodle_recordset.php index 063a33f674..3122b7035c 100644 --- a/lib/dml/pdo_moodle_recordset.php +++ b/lib/dml/pdo_moodle_recordset.php @@ -22,7 +22,8 @@ class pdo_moodle_recordset extends moodle_recordset { } public function key() { - return $this->rowCount; + /// return first column value as key + return reset($this->fields); } public function next() { -- 2.39.5