Browse Source

convert a couple of get_records to recordset - memory usage in attendance is nasty.

MOODLE_26_STABLE
Dan Marsden 11 years ago
parent
commit
bd11e0e4da
  1. 3
      lib.php
  2. 3
      locallib.php

3
lib.php

@ -54,12 +54,13 @@ function attendance_supports($feature) {
function att_add_default_statuses($attid) {
global $DB;
$statuses = $DB->get_records('attendance_statuses', array('attendanceid'=> 0), 'id');
$statuses = $DB->get_recordset('attendance_statuses', array('attendanceid'=> 0), 'id');
foreach ($statuses as $st) {
$rec = $st;
$rec->attendanceid = $attid;
$DB->insert_record('attendance_statuses', $rec);
}
$statuses->close();
}
function attendance_add_instance($attendance) {

3
locallib.php

@ -1267,12 +1267,13 @@ class attendance {
global $DB;
$now = time();
$sessions = $DB->get_records_list('attendance_sessions', 'id', $sessionsids);
$sessions = $DB->get_recordset_list('attendance_sessions', 'id', $sessionsids);
foreach ($sessions as $sess) {
$sess->duration = $duration;
$sess->timemodified = $now;
$DB->update_record('attendance_sessions', $sess);
}
$sessions->close();
add_to_log($this->course->id, 'attendance', 'sessions duration updated', $this->url_manage(),
get_string('sessionsids', 'attendance').implode(', ', $sessionsids), $this->cm->id);
}

Loading…
Cancel
Save