From a9ee15cf405bd61c50856d3cc47ce6ecdfac0841 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Wed, 26 Jun 2013 20:48:01 +0200 Subject: [PATCH] Use Doctrine platform to add limit and offset to query --- lib/db.php | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/lib/db.php b/lib/db.php index 8b2f36aac62..ac9ed77898f 100644 --- a/lib/db.php +++ b/lib/db.php @@ -207,22 +207,11 @@ class OC_DB { static public function prepare( $query , $limit=null, $offset=null ) { if (!is_null($limit) && $limit != -1) { - //Doctrine does not handle limit and offset. - //FIXME: check limit notation for other dbs - //the following sql thus might needs to take into account db ways of representing it - //(oracle has no LIMIT / OFFSET) - $limit = (int)$limit; - $limitsql = ' LIMIT ' . $limit; - if (!is_null($offset)) { - $offset = (int)$offset; - $limitsql .= ' OFFSET ' . $offset; - } - //insert limitsql - if (substr($query, -1) == ';') { //if query ends with ; - $query = substr($query, 0, -1) . $limitsql . ';'; - } else { - $query.=$limitsql; + if ($limit === -1) { + $limit = null; } + $platform = self::$connection->getDatabasePlatform(); + $query = $platform->modifyLimitQuery($query, $limit, $offset); } else { if (isset(self::$preparedQueries[$query]) and self::$cachingEnabled) { return self::$preparedQueries[$query]; -- 2.39.5