1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-05 13:47:33 +02:00

Correct limit and offset for Firebird Driver (#221)

SELECT [FIRST (<int-expr>)] [SKIP (<int-expr>)] <columns> FROM ...
This commit is contained in:
aldria
2016-05-27 03:48:06 +02:00
committed by David Grudl
parent 2571e54f3c
commit b7d84b90ef

View File

@@ -333,9 +333,9 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
*/
public function applyLimit(& $sql, $limit, $offset)
{
if ($limit >= 0 && $offset > 0) {
// see http://scott.yang.id.au/2004/01/limit-in-select-statements-in-firebird/
$sql = 'SELECT FIRST ' . (int) $limit . ($offset > 0 ? ' SKIP ' . (int) $offset : '') . ' * FROM (' . $sql . ')';
if ($limit > 0 || $offset > 0) {
// http://www.firebirdsql.org/refdocs/langrefupd20-select.html
$sql = 'SELECT ' . ($limit > 0 ? 'FIRST ' . (int) $limit : '') . ($offset > 0 ? ' SKIP ' . (int) $offset : '') . ' * FROM (' . $sql . ')';
}
}