DeLIMITing Moodle core. Now the new $limitfrom,

$limitnum parameters are used instead. MDL-7168

Merged from MOODLE_17_STABLE
This commit is contained in:
stronk7 2006-10-24 22:00:29 +00:00
parent 72f9446056
commit 0217757b09
5 changed files with 18 additions and 27 deletions

View File

@ -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');

View 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

View 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) {

View File

@ -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;
}

View File

@ -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);
?>