summaryrefslogtreecommitdiffstats
path: root/lib/db.php
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2013-06-26 20:48:01 +0200
committerBart Visscher <bartv@thisnet.nl>2013-06-26 20:48:01 +0200
commita9ee15cf405bd61c50856d3cc47ce6ecdfac0841 (patch)
tree83cc72fb9fe520ab7ea3dea8cddd887a1a7a629a /lib/db.php
parent21f87d63cf9ebfeea8113efe08418b7d2d445aef (diff)
downloadnextcloud-server-a9ee15cf405bd61c50856d3cc47ce6ecdfac0841.tar.gz
nextcloud-server-a9ee15cf405bd61c50856d3cc47ce6ecdfac0841.zip
Use Doctrine platform to add limit and offset to query
Diffstat (limited to 'lib/db.php')
-rw-r--r--lib/db.php19
1 files 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];