From 1d5d23a1de5a490595d8bb7ea81b8bda48b8feeb Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Mon, 25 Feb 2013 21:46:03 +0100 Subject: Move limit/offset handling to Connection wrapper --- lib/db/connection.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/db') diff --git a/lib/db/connection.php b/lib/db/connection.php index 763251c1903..c8695b13190 100644 --- a/lib/db/connection.php +++ b/lib/db/connection.php @@ -50,8 +50,12 @@ class Connection extends \Doctrine\DBAL\Connection { */ public function prepare( $statement, $limit=null, $offset=null ) { $statement = $this->replaceTablePrefix($statement); - if (!is_null($limit) && $limit != -1) { - // TODO: limit & offset + if ($limit === -1) { + $limit = null; + } + if (!is_null($limit)) { + $platform = $this->getDatabasePlatform(); + $statement = $platform->modifyLimitQuery($statement, $limit, $offset); } else { if (isset($this->preparedQueries[$statement]) && $this->cachingQueryStatementEnabled) { return $this->preparedQueries[$statement]; @@ -59,7 +63,7 @@ class Connection extends \Doctrine\DBAL\Connection { } $rawQuery = $statement; $result = parent::prepare($statement); - if ((is_null($limit) || $limit == -1) && $this->cachingQueryStatementEnabled) { + if (is_null($limit) && $this->cachingQueryStatementEnabled) { $this->preparedQueries[$rawQuery] = $result; } return $result; -- cgit v1.2.3