From bd11e0e4daffea76b673be75850e187c3a99fe13 Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Fri, 20 Dec 2013 09:02:38 +1300 Subject: [PATCH] convert a couple of get_records to recordset - memory usage in attendance is nasty. --- lib.php | 3 ++- locallib.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib.php b/lib.php index 737d5e7..134288b 100644 --- a/lib.php +++ b/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) { diff --git a/locallib.php b/locallib.php index d52ceed..2977b34 100644 --- a/locallib.php +++ b/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); }