Horde_Db_Adapter::addLimitOffset PHP Method

addLimitOffset() public method

Appends +LIMIT+ and +OFFSET+ options to a SQL statement.
public addLimitOffset ( string $sql, array $options ) : string
$sql string SQL statement.
$options array TODO
return string
    public function addLimitOffset($sql, $options);

Usage Example

Example #1
0
 /**
  *  Return the current value of the modseq. We take the MAX of the
  *  horde_histories table instead of the value of the horde_histories_modseq
  *  table to ensure we never miss an entry if we query the history system
  *  between the time we call nextModSeq() and the time the new entry is
  *  written.
  *
  * @param string $parent  Restrict to entries a specific parent.
  *
  * @return integer|boolean  The highest used modseq value, false if no history.
  */
 public function getHighestModSeq($parent = null)
 {
     $sql = 'SELECT history_modseq FROM horde_histories';
     if (!empty($parent)) {
         $sql .= ' WHERE object_uid LIKE ' . $this->_db->quote($parent . ':%');
     }
     $sql .= ' ORDER BY history_modseq DESC';
     $sql = $this->_db->addLimitOffset($sql, array('limit' => 1));
     try {
         $modseq = $this->_db->selectValue($sql);
     } catch (Horde_Db_Exception $e) {
         throw new Horde_History_Exception($e);
     }
     if (is_null($modseq) || $modseq === false) {
         try {
             $modseq = $this->_db->selectValue('SELECT MAX(history_modseq) FROM horde_histories_modseq');
         } catch (Horde_Db_Exception $e) {
             throw new Horde_History_Exception($e);
         }
         if (!empty($modseq)) {
             return $modseq;
         } else {
             return false;
         }
     }
     return $modseq;
 }
All Usage Examples Of Horde_Db_Adapter::addLimitOffset