From 37c47abaca93252f4057e678bca2e7ae6f2ea177 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Mon, 23 Oct 2006 16:03:52 +0000 Subject: [PATCH] Suppress all the uses of LIMIT in the get_field_sql() calls. MDL-7173 Merged from MOODLE_17_STABLE --- admin/cron.php | 2 +- admin/report/courseoverview/index.php | 13 ++++++------- course/report/stats/lib.php | 8 ++++---- course/user.php | 6 +++--- lib/statslib.php | 4 ++-- 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/admin/cron.php b/admin/cron.php index db0b9ec820..4f17ce9568 100644 --- a/admin/cron.php +++ b/admin/cron.php @@ -291,7 +291,7 @@ if (!empty($CFG->statsmaxruntime)) { $time = $CFG->statsmaxruntime+(60*30); // add on half an hour just to make sure (it could take that long to break out of the loop) } - if (!get_field_sql('SELECT id FROM '.$CFG->prefix.'stats_daily LIMIT 1')) { + if (!get_field_sql('SELECT id FROM '.$CFG->prefix.'stats_daily')) { // first run, set another lock. we'll check for this in subsequent runs to set the timeout to later for the normal lock. set_cron_lock('statsfirstrunlock',true,$time,true); $firsttime = true; diff --git a/admin/report/courseoverview/index.php b/admin/report/courseoverview/index.php index 87eec1d975..608041bfa2 100644 --- a/admin/report/courseoverview/index.php +++ b/admin/report/courseoverview/index.php @@ -31,9 +31,9 @@ $tableprefix = $CFG->prefix.'stats_'; - $earliestday = get_field_sql('SELECT timeend FROM '.$tableprefix.'daily ORDER BY timeend LIMIT 1'); - $earliestweek = get_field_sql('SELECT timeend FROM '.$tableprefix.'weekly ORDER BY timeend LIMIT 1'); - $earliestmonth = get_field_sql('SELECT timeend FROM '.$tableprefix.'monthly ORDER BY timeend LIMIT 1'); + $earliestday = get_field_sql('SELECT timeend FROM '.$tableprefix.'daily ORDER BY timeend'); + $earliestweek = get_field_sql('SELECT timeend FROM '.$tableprefix.'weekly ORDER BY timeend'); + $earliestmonth = get_field_sql('SELECT timeend FROM '.$tableprefix.'monthly ORDER BY timeend'); if (empty($earliestday)) $earliestday = time(); if (empty($earliestweek)) $earliestweek = time(); @@ -66,18 +66,17 @@ $param = stats_get_parameters($time,$report,SITEID,STATS_MODE_RANKED); if (!empty($param->sql)) { - $sql = $param->sql ." LIMIT ".$numcourses; + $sql = $param->sql; } else { $sql = "SELECT courseid,".$param->fields." FROM ".$CFG->prefix.'stats_'.$param->table ." WHERE timeend >= ".$param->timeafter.' AND stattype = \'activity\'' ." GROUP BY courseid " .$param->extras - ." ORDER BY ".$param->orderby - ." LIMIT ".$numcourses; + ." ORDER BY ".$param->orderby; } error_log($sql); - $courses = get_records_sql($sql); + $courses = get_records_sql($sql, 0, $numcourses); if (empty($courses)) { notify(get_string('statsnodata')); diff --git a/course/report/stats/lib.php b/course/report/stats/lib.php index c262513606..f22a7432dc 100644 --- a/course/report/stats/lib.php +++ b/course/report/stats/lib.php @@ -45,9 +45,9 @@ $tableprefix = $CFG->prefix.'stats_user_'; } - $earliestday = get_field_sql('SELECT timeend FROM '.$tableprefix.'daily ORDER BY timeend LIMIT 1'); - $earliestweek = get_field_sql('SELECT timeend FROM '.$tableprefix.'weekly ORDER BY timeend LIMIT 1'); - $earliestmonth = get_field_sql('SELECT timeend FROM '.$tableprefix.'monthly ORDER BY timeend LIMIT 1'); + $earliestday = get_field_sql('SELECT timeend FROM '.$tableprefix.'daily ORDER BY timeend'); + $earliestweek = get_field_sql('SELECT timeend FROM '.$tableprefix.'weekly ORDER BY timeend'); + $earliestmonth = get_field_sql('SELECT timeend FROM '.$tableprefix.'monthly ORDER BY timeend'); if (empty($earliestday)) $earliestday = time(); if (empty($earliestweek)) $earliestweek = time(); @@ -61,4 +61,4 @@ } -?> \ No newline at end of file +?> diff --git a/course/user.php b/course/user.php index 5560171144..3b7329b552 100644 --- a/course/user.php +++ b/course/user.php @@ -101,9 +101,9 @@ notify ($statsstatus); } - $earliestday = get_field_sql('SELECT timeend FROM '.$CFG->prefix.'stats_user_daily ORDER BY timeend LIMIT 1'); - $earliestweek = get_field_sql('SELECT timeend FROM '.$CFG->prefix.'stats_user_weekly ORDER BY timeend LIMIT 1'); - $earliestmonth = get_field_sql('SELECT timeend FROM '.$CFG->prefix.'stats_user_monthly ORDER BY timeend LIMIT 1'); + $earliestday = get_field_sql('SELECT timeend FROM '.$CFG->prefix.'stats_user_daily ORDER BY timeend'); + $earliestweek = get_field_sql('SELECT timeend FROM '.$CFG->prefix.'stats_user_weekly ORDER BY timeend'); + $earliestmonth = get_field_sql('SELECT timeend FROM '.$CFG->prefix.'stats_user_monthly ORDER BY timeend'); if (empty($earliestday)) $earliestday = time(); if (empty($earliestweek)) $earliestweek = time(); diff --git a/lib/statslib.php b/lib/statslib.php index 1c64226cd5..1f08cd8f78 100644 --- a/lib/statslib.php +++ b/lib/statslib.php @@ -468,7 +468,7 @@ function stats_get_start_from($str) { global $CFG; // if it's not our first run, just return the most recent. - if ($timeend = get_field_sql('SELECT timeend FROM '.$CFG->prefix.'stats_'.$str.' ORDER BY timeend DESC LIMIT 1')) { + if ($timeend = get_field_sql('SELECT timeend FROM '.$CFG->prefix.'stats_'.$str.' ORDER BY timeend DESC')) { return $timeend; } @@ -476,7 +476,7 @@ function stats_get_start_from($str) { $function = 'stats_get_base_'.$str; switch ($CFG->statsfirstrun) { case 'all': - return $function(get_field_sql('SELECT time FROM '.$CFG->prefix.'log ORDER BY time LIMIT 1')); + return $function(get_field_sql('SELECT time FROM '.$CFG->prefix.'log ORDER BY time')); break; case 'none': return $function(strtotime('-1 day',time())); -- 2.39.5