From d669160891000b33fbdf51b816f2655ce0c694d2 Mon Sep 17 00:00:00 2001 From: skodak Date: Tue, 28 Oct 2008 12:14:09 +0000 Subject: [PATCH] MDL-15070 dml: recordset rewinding now forbidden - not all databases support it, sorry --- lib/dml/adodb_moodle_recordset.php | 4 ---- lib/dml/moodle_recordset.php | 7 +++++-- lib/dml/mysqli_native_moodle_recordset.php | 4 ---- lib/dml/pdo_moodle_recordset.php | 7 ------- lib/dml/pgsql_native_moodle_recordset.php | 4 ---- user/index.php | 14 ++++++-------- 6 files changed, 11 insertions(+), 29 deletions(-) diff --git a/lib/dml/adodb_moodle_recordset.php b/lib/dml/adodb_moodle_recordset.php index 0b325ea7341..81a44ecbe2c 100644 --- a/lib/dml/adodb_moodle_recordset.php +++ b/lib/dml/adodb_moodle_recordset.php @@ -27,10 +27,6 @@ class adodb_moodle_recordset extends moodle_recordset { $this->rs->MoveNext(); } - public function rewind() { - $this->rs->MoveFirst(); - } - public function valid() { return !$this->rs->EOF; } diff --git a/lib/dml/moodle_recordset.php b/lib/dml/moodle_recordset.php index 4c18fe532d6..8aa6f76ab50 100644 --- a/lib/dml/moodle_recordset.php +++ b/lib/dml/moodle_recordset.php @@ -31,10 +31,13 @@ abstract class moodle_recordset implements Iterator { //public abstract function next(); /** - * Revinds back to the first row + * Revinds are not supported! * @return void */ - //public abstract function rewind(); + public function rewind() { + // no seeking, sorry - let's ignore it ;-) + return; + } /** * Did we reach the end? diff --git a/lib/dml/mysqli_native_moodle_recordset.php b/lib/dml/mysqli_native_moodle_recordset.php index 7917676a4c9..13e7577722d 100644 --- a/lib/dml/mysqli_native_moodle_recordset.php +++ b/lib/dml/mysqli_native_moodle_recordset.php @@ -40,10 +40,6 @@ class mysqli_native_moodle_recordset extends moodle_recordset { $this->current = $this->fetch_next(); } - public function rewind() { - // we can not seek, sorry - let's ignore it ;-) - } - public function valid() { return !empty($this->current); } diff --git a/lib/dml/pdo_moodle_recordset.php b/lib/dml/pdo_moodle_recordset.php index 3122b7035c4..aa65dcc3f42 100644 --- a/lib/dml/pdo_moodle_recordset.php +++ b/lib/dml/pdo_moodle_recordset.php @@ -34,13 +34,6 @@ class pdo_moodle_recordset extends moodle_recordset { return $this->fields !== false; } - public function rewind() { - $this->fields = $this->sth->fetch(); - if ($this->fields) { - $this->rowCount = 0; - } - } - public function valid() { if($this->rowCount < 0) { $this->rewind(); diff --git a/lib/dml/pgsql_native_moodle_recordset.php b/lib/dml/pgsql_native_moodle_recordset.php index 65d81a0e643..eb2d5261766 100644 --- a/lib/dml/pgsql_native_moodle_recordset.php +++ b/lib/dml/pgsql_native_moodle_recordset.php @@ -58,10 +58,6 @@ class pgsql_native_moodle_recordset extends moodle_recordset { $this->current = $this->fetch_next(); } - public function rewind() { - // we can not seek, sorry - let's ignore it ;-) - } - public function valid() { return !empty($this->current); } diff --git a/user/index.php b/user/index.php index a02da92b58c..07133245118 100644 --- a/user/index.php +++ b/user/index.php @@ -531,16 +531,14 @@ // of rows anyway. On a large course it will explode badly... // if ($mode===MODE_ENROLDETAILS) { - $userids = array(); - - foreach ($userlist as $user) { - $userids[] = $user->id; + if ($context->id != $frontpagectx->id) { + $userids = $DB->get_fieldset_sql("SELECT DISTINCT u.id $from $where $wheresearch $sort", $params, + $table->get_page_start(), $table->get_page_size()); + } else { + $userids = $DB->get_fieldset_sql("SELECT u.id $from $where $wheresearch $sort", $params, + $table->get_page_start(), $table->get_page_size()); } $userlist_extra = get_participants_extra($userids, $avoidroles, $course, $context); - - // Only Oracle cannot seek backwards - // and must re-query... - $userlist->rewind(); } if ($context->id == $frontpagectx->id) {