$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');
$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
$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) {
$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;
}
}
$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);
+?>