MDL-17038 - refine query to limit size of returned data.

Author: Peter Bulmer <peter.bulmer@catalyst.net.nz>
This commit is contained in:
peterbulmer 2008-10-30 01:16:06 +00:00
parent 1500142bfb
commit 6ff7d16b25

View File

@ -772,32 +772,28 @@ class auth_plugin_mnet extends auth_plugin_base {
join("\n", $mnet_request->error));
break;
}
$query = "SELECT
l.id as remoteid,
l.time,
l.userid,
l.ip,
l.course,
l.module,
l.cmid,
l.action,
l.url,
l.info,
c.fullname as coursename,
c.modinfo as modinfo,
u.username
FROM
{user} u,
{log} l,
{course} c
WHERE
l.userid = u.id AND
u.mnethostid = ? AND
l.id > ? AND
c.id = l.course
ORDER BY
remoteid ASC";
$query = "
SELECT
mhostlogs.remoteid, mhostlogs.time, mhostlogs.userid, mhostlogs.ip,
mhostlogs.course, mhostlogs.module, mhostlogs.cmid, mhostlogs.action,
mhostlogs.url, mhostlogs.info, mhostlogs.username, c.fullname as coursename,
c.modinfo
FROM
(
SELECT
l.id as remoteid, l.time, l.userid, l.ip, l.course, l.module, l.cmid,
l.action, l.url, l.info, u.username
FROM
{user} u
INNER JOIN {log} l on l.userid = u.id
WHERE
u.mnethostid = ?
AND l.id > ?
ORDER BY remoteid ASC
LIMIT 500
) mhostlogs
INNER JOIN {course} c on c.id = mhostlogs.course
ORDER by mhostlogs.remoteid ASC";
$results = $DB->get_records_sql($query, array($mnethostid, $mnet_request->response['last log id']));