english/libraries/joomla/database/database/sqlsrv.php
/**
	 * Method to wrap an SQL statement to provide a LIMIT and OFFSET behavior for scrolling through a result set.
	 *
	 * @param   string   $sql     The SQL statement to process.
	 * @param   integer  $offset  The affected row offset to set.
	 * @param   integer  $limit   The maximum affected rows to set.
	 *
	 * @return  string   The processed SQL statement.
	 *
	 * @since   11.1
	 */
Method to wrap an SQL statement to provide a LIMIT and OFFSET behavior for scrolling through a result set.
@param   string   $sql     The SQL statement to process.
@param   integer  $offset  The affected row offset to set.
@param   integer  $limit   The maximum affected rows to set.

@return  string   The processed SQL statement.


Method to wrap an SQL statement to provide a LIMIT and OFFSET behavior for scrolling through a result set . @param string $sql The SQL statement to process . @param integer $offset The affected row offset to set . @param integer $limit The maximum affected rows to set . @return string The processed SQL statement .
protected function _limit($sql, $limit, $offset)
	{
		$orderBy = stristr($sql, 'ORDER BY');
		if (is_null($orderBy) || empty($orderBy)) {
			$orderBy = 'ORDER BY (select 0)';
		}
		$sql = str_ireplace($orderBy, '', $sql);
		$rowNumberText = ',ROW_NUMBER() OVER ('.$orderBy.') AS RowNumber FROM ';
		$sql = preg_replace('/\\s+FROM/','\\1 '.$rowNumberText.' ', $sql, 1);
		$sql = 'SELECT TOP '.$this->limit.' * FROM ('.$sql.') _myResults WHERE RowNumber > '.$this->offset;
		return $sql;
	}
protected function _limit ( $ sql , $ limit , $ offset ) { $ orderBy = stristr ( $ sql , 'ORDER BY' ) ; if ( is_null ( $ orderBy ) || empty ( $ orderBy ) ) { $ orderBy = 'ORDER BY (select 0)' ; } $ sql = str_ireplace ( $ orderBy , '' , $ sql ) ; $ rowNumberText = ',ROW_NUMBER() OVER (' . $ orderBy . ') AS RowNumber FROM ' ; $ sql = preg_replace ( '/\\s+FROM/' , '\\1 ' . $ rowNumberText . ' ' , $ sql , 1 ) ; $ sql = 'SELECT TOP ' . $ this -> limit . ' * FROM (' . $ sql . ') _myResults WHERE RowNumber > ' . $ this -> offset ; return $ sql ; }
Method to wrap an SQL statement to provide a LIMIT and OFFSET behavior for scrolling through a result set.
Method to wrap an SQL statement to provide a LIMIT and OFFSET behavior for scrolling through a result set .