$limit[0] += ceil($this->_postingsCount / $limit[1]) + 1;
}
$limit[0] = ($limit[0] - 1) * $limit[1];
-
- $query .= ' LIMIT ' . $limit[0];
- if (isset($limit[1])) {
- $query .= ', ' . $limit[1];
- }
+ /* Log the query at a DEBUG log level. */
+ Horde::logMessage(sprintf('Fima_Driver_sql::retrievePostings() limitQuery: %s', $query), 'DEBUG');
+ $result = $this->_db->queryLimit($query, $limit[0], $limit[1], $values);
+ } else {
+ /* Log the query at a DEBUG log level. */
+ Horde::logMessage(sprintf('Fima_Driver_sql::retrievePostings(): %s', $query), 'DEBUG');
+ $result = $this->_db->query($query, $values);
}
- /* Log the query at a DEBUG log level. */
- Horde::logMessage(sprintf('Fima_Driver_sql::retrievePostings(): %s', $query), 'DEBUG');
-
/* Execute the query. */
$result = $this->_db->query($query, $values);
if (isset($result) && !is_a($result, 'PEAR_Error')) {
{
$sql = 'SELECT user_uid FROM ' . $this->_params['online']
. ' WHERE user_uid <> "" AND user_uid <> "0" '
- . ' ORDER BY time_last_click DESC LIMIT 0, ' . (int)$limit;
+ . ' ORDER BY time_last_click DESC';
- return $this->_db->getCol($sql);
+ $result = $this->_db->limitQuery($sql, 0, $limit);
+ $value = $result->fetchRow(DB_FETCHMODE_ORDERED);
+ return $value[0];
}
/**
{
if ($online) {
$sql = 'SELECT u.user_uid FROM ' . $this->_params['table'] . ' u, .' . $this->_params['online'] . ' o '
- . ' WHERE u.user_picture = 1 AND o.user_uid = u.user_uid ORDER BY RAND() LIMIT 0, ' . (int)$limit;
+ . ' WHERE u.user_picture = 1 AND o.user_uid = u.user_uid ORDER BY RAND()';
} else {
$sql = 'SELECT user_uid FROM ' . $this->_params['table']
- . ' WHERE user_picture = 1 ORDER BY RAND() LIMIT 0, ' . (int)$limit;
- }
+ . ' WHERE user_picture = 1 ORDER BY RAND()';
+
+ $result = $this->_db->limitQuery($sql, 0, $limit);
+ $value = $result->fetchRow(DB_FETCHMODE_ORDERED);
- return $this->_db->getCol($sql);
+ return $value[0];
}
/**
'n.status = ? AND n.publish <= NOW() ' .
'AND (n.category1 = ? OR n.category2 = ?) ' .
'AND nl.lang = ? AND n.id = nl.id ' .
- 'ORDER BY n.publish DESC ' .
- 'LIMIT 0, ' . $this->_params['limit'];
+ 'ORDER BY n.publish DESC';
$params = array(News::CONFIRMED, $this->_params['category'], $this->_params['category'], $GLOBALS['registry']->preferredLang());
- $rows = $GLOBALS['news']->db->getAll($query, $params, DB_FETCHMODE_ASSOC);
- if ($rows instanceof PEAR_Error) {
- return $rows->getDebugInfo();
+ $res = $GLOBALS['news']->db->limitQuery($query, 0, $this->_params['limit'], $params);
+ if ($res instanceof PEAR_Error) {
+ return $res->getDebugInfo();
+ }
+ $rows = array();
+ while ($res->fetchInto($row, DB_FETCHMODE_ASSOC)) {
+ $rows[$row['id']] = $row;
}
-
$view = new News_View();
$view->news = $rows;
$view->moreurl = Horde_Util::addParameter(Horde::applicationUrl('browse.php'), 'category', $this->_params['category']);
$params[] = (int)$this->_params['category'];
}
- $query .= 'ORDER BY n.publish DESC ' .
- 'LIMIT 0, ' . $this->_params['limit'];
-
- $rows = $GLOBALS['news']->db->getAll($query, $params, DB_FETCHMODE_ASSOC);
- if ($rows instanceof PEAR_Error) {
- return $rows->getDebugInfo();
+ $query .= 'ORDER BY n.publish DESC';
+ $res = $GLOBALS['news']->db->queryLimit($query, 0, $this->_params['limit'], $params);
+ if ($res instanceof PEAR_Error) {
+ return $res->getDebugInfo();
+ }
+ $rows = array();
+ while ($res->fetchInto($row, DB_FETCHMODE_ASSOC)) {
+ $rows[$row['id']] = $row;
}
-
$view = new News_View();
$view->news = $rows;
$view->moreurl = Horde::applicationUrl('browse.php');
'FROM ' . $GLOBALS['news']->prefix . ' AS n, ' . $GLOBALS['news']->prefix . '_body AS nl WHERE ' .
'n.status = ? AND n.publish <= NOW() AND n.trackbacks > ? ' .
'AND nl.lang = ? AND n.id = nl.id ' .
- 'ORDER BY n.publish DESC ' .
- 'LIMIT 0, ' . $this->_params['limit'];
+ 'ORDER BY n.publish DESC';
$params = array(News::CONFIRMED, 0, $GLOBALS['registry']->preferredLang());
- $rows = $GLOBALS['news']->db->getAll($query, $params, DB_FETCHMODE_ASSOC);
- if ($rows instanceof PEAR_Error) {
- return $rows->getDebugInfo();
+ $res = $GLOBALS['news']->db->limitQuery($query, 0, $this->_params['limit'], $params);
+ if ($res instanceof PEAR_Error) {
+ return $res->getDebugInfo();
+ }
+ while ($res->fetchInto($row, DB_FETCHMODE_ASSOC)) {
+ $rows[$row['id']] = $row;
}
-
$view = new News_View();
$view->news = $rows;
'FROM ' . $GLOBALS['news']->prefix . ' AS n, ' . $GLOBALS['news']->prefix . '_body AS nl WHERE ' .
'n.status = ? AND n.publish <= NOW() AND n.publish > ?' .
'AND nl.lang = ? AND n.id = nl.id ' .
- 'ORDER BY n.comments DESC ' .
- 'LIMIT 0, ' . $this->_params['limit'];
+ 'ORDER BY n.comments DESC ';
$younger = $_SERVER['REQUEST_TIME'] - $this->_params['days'] * 86400;
$params = array(News::CONFIRMED, date('Y-m-d', $younger), $GLOBALS['registry']->preferredLang());
- $rows = $GLOBALS['news']->db->getAll($query, $params, DB_FETCHMODE_ASSOC);
- if ($rows instanceof PEAR_Error) {
- return $rows->getDebugInfo();
+ $res = $GLOBALS['news']->db->limitQuery($query, 0, $this->_params['limit'], $params);
+ if ($res instanceof PEAR_Error) {
+ return $res->getDebugInfo();
+ }
+ $rows = array();
+ while ($res->fetchInto($row, DB_FETCHMODE_ASSOC)) {
+ $rows[$row['id']] = $row;
}
-
$view = new News_View();
$view->news = $rows;
'FROM ' . $GLOBALS['news']->prefix . ' AS n, ' . $GLOBALS['news']->prefix . '_body AS nl WHERE ' .
'n.status = ? AND n.publish <= NOW() AND n.publish > ?' .
'AND nl.lang = ? AND n.id = nl.id ' .
- 'ORDER BY n.view_count DESC ' .
- 'LIMIT 0, ' . $this->_params['limit'];
+ 'ORDER BY n.view_count DESC';
$younger = $_SERVER['REQUEST_TIME'] - $this->_params['days'] * 86400;
$params = array(News::CONFIRMED, date('Y-m-d', $younger), $GLOBALS['registry']->preferredLang());
- $rows = $GLOBALS['news']->db->getAll($query, $params, DB_FETCHMODE_ASSOC);
- if ($rows instanceof PEAR_Error) {
- return $rows->getDebugInfo();
+ $res = $GLOBALS['news']->db->queryLimit($query, 0, $this->_params['limit'], $params);
+ if ($res instanceof PEAR_Error) {
+ return $res->getDebugInfo();
+ }
+ $rows = array();
+ while ($res->fetchInto($row, DB_FETCHMODE_ASSOC)) {
+ $rows[$row['id']] = $row;
}
-
$view = new News_View();
$view->news = $rows;
function lastEntry($studentid)
{
$query = 'SELECT object_time FROM ' . $this->_params['objects_table'] .
- ' WHERE class_id = ? AND student_id = ? ORDER BY object_time DESC LIMIT 1';
+ ' WHERE class_id = ? AND student_id = ? ORDER BY object_time DESC';
$values = array($this->_class, $studentid);
/* Log the query at a DEBUG log level. */
Horde::logMessage(sprintf('Skoli_Driver_sql::lastEntry(): %s', $query), 'DEBUG');
/* Attempt the select query. */
- $lastentry = $this->_db->getRow($query, $values, DB_FETCHMODE_ORDERED);
+ $lastentry = $this->_db->limitQuery($query, 0, 1);
+ $lastentry = $lastentry->fetchRow(DB_FETCHMODE_ORDERED);
/* Return an error immediately if the query failed. */
if (is_a($lastentry, 'PEAR_Error')) {