diff --git a/admin/report/courseoverview/reportsgraph.php b/admin/report/courseoverview/reportsgraph.php index c3c36181b14..205df01c630 100644 --- a/admin/report/courseoverview/reportsgraph.php +++ b/admin/report/courseoverview/reportsgraph.php @@ -17,17 +17,16 @@ $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'); diff --git a/blocks/blog_tags/block_blog_tags.php b/blocks/blog_tags/block_blog_tags.php index fae460d8b1b..ed94a3d9034 100644 --- a/blocks/blog_tags/block_blog_tags.php +++ b/blocks/blog_tags/block_blog_tags.php @@ -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 diff --git a/mod/chat/lib.php b/mod/chat/lib.php index 48b7605ce8e..cbe9e6bf28c 100644 --- a/mod/chat/lib.php +++ b/mod/chat/lib.php @@ -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) { diff --git a/mod/data/rsslib.php b/mod/data/rsslib.php index f8d2f174c41..cf874ca0a35 100644 --- a/mod/data/rsslib.php +++ b/mod/data/rsslib.php @@ -38,12 +38,11 @@ $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; } diff --git a/mod/glossary/sql.php b/mod/glossary/sql.php index 64dd5d06fe6..7b7db4f1b6c 100644 --- a/mod/glossary/sql.php +++ b/mod/glossary/sql.php @@ -295,17 +295,11 @@ } $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); +?>