MDL-15070 dml: recordset rewinding now forbidden - not all databases support it, sorry

This commit is contained in:
skodak
2008-10-28 12:14:09 +00:00
parent 7063c802fa
commit d669160891
6 changed files with 11 additions and 29 deletions
-4
View File
@@ -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;
}
+5 -2
View File
@@ -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?
@@ -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);
}
-7
View File
@@ -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();
@@ -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);
}
+6 -8
View File
@@ -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) {