Use Doctrine platform to add limit and offset to query

This commit is contained in:
Bart Visscher 2013-06-26 20:48:01 +02:00
parent 21f87d63cf
commit a9ee15cf40
1 changed files with 4 additions and 15 deletions

View File

@ -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];