]> git.mjollnir.org Git - moodle.git/commitdiff
Suppress all the uses of LIMIT in the get_field_sql() calls. MDL-7173
authorstronk7 <stronk7>
Mon, 23 Oct 2006 16:03:52 +0000 (16:03 +0000)
committerstronk7 <stronk7>
Mon, 23 Oct 2006 16:03:52 +0000 (16:03 +0000)
Merged from MOODLE_17_STABLE

admin/cron.php
admin/report/courseoverview/index.php
course/report/stats/lib.php
course/user.php
lib/statslib.php

index db0b9ec82098b8529e5db3386e4ab0e8ec3d4e22..4f17ce956819c35142c328bdc380c3e0064f787b 100644 (file)
             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;
index 87eec1d975feddc0848823758d93bc997570c1a2..608041bfa2197103e50e6339b4b9b5d5cb547088 100644 (file)
@@ -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();
         $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'));
index c262513606cf65c379a705074b5b46659d714932..f22a7432dc6047f02443960c66ab9f47d7d0685d 100644 (file)
@@ -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
+?>
index 5560171144635b800ef656df0c702b3b68a452cb..3b7329b552ae2de1f56ad8cad179c5d8fba42bf0 100644 (file)
                 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();
index 1c64226cd54864859d803fb08a6e0e04437757b3..1f08cd8f78339ba8e235cd90a40286334ba8d01c 100644 (file)
@@ -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()));