diff options
author | Timothy Warren <tim@timshomepage.net> | 2012-02-29 17:58:20 +0100 |
---|---|---|
committer | Timothy Warren <tim@timshomepage.net> | 2012-02-29 17:58:20 +0100 |
commit | 56784f67c35c75b706c5f9fc2950e58356e7ecec (patch) | |
tree | 2ac955e351e5676d1d2b5e08fa4062d0e3bd7e53 /system/database/drivers/interbase/interbase_driver.php | |
parent | 7980923d0c7e62fb545e3b750dfe5cec4a057b48 (diff) |
Finally figured out limit statement
Diffstat (limited to 'system/database/drivers/interbase/interbase_driver.php')
-rw-r--r-- | system/database/drivers/interbase/interbase_driver.php | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index b49d1fa74..e55a476bb 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -601,7 +601,31 @@ SQL; */ protected function _limit($sql, $limit, $offset) { - //There doesn't seem to be a limit clause? + // Keep the current sql string safe for a moment + $orig_sql = $sql; + + // Limit clause depends on if Interbase or Firebird + if (stripos($this->_version(), 'firebird') !== FALSE) + { + $sql = 'FIRST '. (int) $limit; + + if ($offset > 0) + { + $sql .= ' SKIP'. (int) $offset; + } + } + else + { + $sql = 'ROWS ' . (int) $limit; + + if ($offset > 0) + { + $sql = 'ROWS '. (int) $offset . ' TO ' . ($limit + $offset); + } + } + + $sql = preg_replace("`SELECT`i", "SELECT {$sql}", $orig_sql); + return $sql; } |