Skip to content

Commit

Permalink
DeLIMITing Moodle core. Now the new $limitfrom,
Browse files Browse the repository at this point in the history
$limitnum parameters are used instead. MDL-7168
  • Loading branch information
stronk7 committed Oct 24, 2006
1 parent e2c0f78 commit eb2d09c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 27 deletions.
7 changes: 3 additions & 4 deletions admin/report/courseoverview/reportsgraph.php
Expand Up @@ -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');
Expand Down
7 changes: 3 additions & 4 deletions blocks/blog_tags/block_blog_tags.php
Expand Up @@ -77,16 +77,15 @@ function get_content() {
$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
Expand Down
8 changes: 4 additions & 4 deletions mod/chat/lib.php
Expand Up @@ -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) {
Expand Down
7 changes: 3 additions & 4 deletions mod/data/rsslib.php
Expand Up @@ -38,12 +38,11 @@ function data_rss_feeds() {
$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;
}

Expand Down
16 changes: 5 additions & 11 deletions mod/glossary/sql.php
Expand Up @@ -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");
?>
$allentries = get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby", $limitfrom, $limitnum);
?>

0 comments on commit eb2d09c

Please sign in to comment.