]> git.mjollnir.org Git - moodle.git/commitdiff
DeLIMITing Moodle core. Now the new $limitfrom,
authorstronk7 <stronk7>
Tue, 24 Oct 2006 22:00:29 +0000 (22:00 +0000)
committerstronk7 <stronk7>
Tue, 24 Oct 2006 22:00:29 +0000 (22:00 +0000)
$limitnum parameters are used instead. MDL-7168

Merged from MOODLE_17_STABLE

admin/report/courseoverview/reportsgraph.php
blocks/blog_tags/block_blog_tags.php
mod/chat/lib.php
mod/data/rsslib.php
mod/glossary/sql.php

index c3c36181b1429de8ffcd8413d52923ae6629c6a2..205df01c630c99a8c7577c41f3543da7e37c46f9 100644 (file)
     $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;
     }
 
-    $courses = get_records_sql($sql);
+    $courses = get_records_sql($sql, 0, $numcourses);
 
     if (empty($courses)) {
         error(get_string('statsnodata'),$CFG->wwwroot.'/'.$CFG->admin.'/report/course/index.php');
index fae460d8b1b51509183ae786452d2c5520b989b4..ed94a3d9034ce71129cbc70ef1d9245e374f9489 100644 (file)
@@ -77,16 +77,15 @@ class block_blog_tags extends block_base {
         $timewithin = $this->config->timewithin * 24 * 60 * 60; /// convert to seconds
 
         $sql  = 'SELECT t.id, t.type, t.text, COUNT(DISTINCT bt.id) as ct ';
-        $sql .= "FROM {$CFG->prefix}tags as t, {$CFG->prefix}blog_tag_instance as bt, {$CFG->prefix}post as p ";
+        $sql .= "FROM {$CFG->prefix}tags t, {$CFG->prefix}blog_tag_instance bt, {$CFG->prefix}post p ";
         $sql .= 'WHERE t.id = bt.tagid ';
         $sql .= 'AND p.id = bt.entryid ';
         $sql .= 'AND (p.publishstate = \'site\' or p.publishstate=\'public\') ';
         $sql .= "AND bt.timemodified > {$timewithin} ";
         $sql .= 'GROUP BY t.id, t.type, t.text ';
-        $sql .= 'ORDER BY ct DESC, t.text ASC ';
-        $sql .= "LIMIT {$this->config->numberoftags} ";
+        $sql .= 'ORDER BY ct DESC, t.text ASC';
 
-        if ($tags = get_records_sql($sql)) {
+        if ($tags = get_records_sql($sql, 0, $this->config->numberoftags)) {
 
         /// There are 2 things to do:
         /// 1. tags with the same count should have the same size class
index 48b7605ce8e7c76c6748d87603e3739fe3be4855..cbe9e6bf28cfef0300a576050858a2912222fbde 100644 (file)
@@ -369,10 +369,10 @@ function chat_get_latest_message($chatid, $groupid=0) {
         $groupselect = "";
     }
 
-    if (!$rs = $db->Execute("SELECT *
-                               FROM {$CFG->prefix}chat_messages
-                              WHERE chatid = '$chatid' $groupselect
-                           ORDER BY timestamp DESC LIMIT 1")) {
+    if (!$rs = $db->SelectLimit("SELECT *
+                                 FROM {$CFG->prefix}chat_messages
+                                 WHERE chatid = '$chatid' $groupselect
+                                 ORDER BY timestamp DESC", 1)) {
         return false;
     }
     if ($rs->RecordCount() == 1) {
index f8d2f174c410fab9c869d039c62e653d24bedbc2..cf874ca0a35e32d8894a26313732b02096011006 100644 (file)
                         $approved = ($data->approval) ? ' AND dr.approved = 1 ' : ' ';
 
                         $sql = 'SELECT dr.* ' .
-                                    "FROM {$CFG->prefix}data_records AS dr " .
+                                    "FROM {$CFG->prefix}data_records dr " .
                                     "WHERE dr.dataid = {$data->id} " .$approved.
-                                    'ORDER BY dr.timecreated DESC ' .
-                                    "LIMIT {$data->rssarticles}";
+                                    'ORDER BY dr.timecreated DESC';
                         
-                        if (!$records = get_records_sql($sql)) {
+                        if (!$records = get_records_sql($sql, 0, $data->rssarticles)) {
                             continue;
                         }
 
index 64dd5d06fe6e192a90c5aedde55ee21a045536b4..7b7db4f1b6cfe42689439c8c9f131294c3fbb99b 100644 (file)
     } 
     $count = count_records_sql("select count(*) $sqlfrom $sqlwhere");
 
-    $sqllimit = '';
+    $limitfrom = $offset;
+    $limitnum = 0;
     
     if ( $offset >= 0 ) {
-        switch ($CFG->dbtype) {
-        case 'postgres7':
-            $sqllimit = " LIMIT $entriesbypage OFFSET $offset";
-        break;
-        case 'mysql':
-            $sqllimit = " LIMIT $offset, $entriesbypage";
-        break;
-        }    
+        $limitnum = $entriesbypage;
     }
-    $allentries = get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby $sqllimit");
-?>
\ No newline at end of file
+    $allentries = get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby", $limitfrom, $limitnum);
+?>