diff --git a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php index 843395473..977353179 100644 --- a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php @@ -1149,33 +1149,6 @@ abstract class AbstractPlatform return false; } - /** - * Adds a LIMIT/OFFSET clause to the query. - * This default implementation writes the syntax "LIMIT x OFFSET y" to the - * query which is supported by MySql, PostgreSql and Sqlite. - * Any database platforms that do not support this syntax should override - * this implementation and provide their own. - * - * @param string $query The SQL string to write to / append to. - * @param mixed $limit - * @param mixed $offset - */ - public function writeLimitClause($query, $limit = false, $offset = false) - { - $limit = (int) $limit; - $offset = (int) $offset; - - if ($limit && $offset) { - $query .= ' LIMIT ' . $limit . ' OFFSET ' . $offset; - } elseif ($limit && ! $offset) { - $query .= ' LIMIT ' . $limit; - } elseif ( ! $limit && $offset) { - $query .= ' LIMIT 999999999999 OFFSET ' . $offset; - } - - return $query; - } - /** * Some platforms need the boolean values to be converted. * Default conversion defined here converts to integers. @@ -1534,14 +1507,14 @@ abstract class AbstractPlatform public function modifyLimitQuery($query, $limit, $offset = null) { - if ( ! is_null($offset)) { - $query .= ' OFFSET ' . $offset; - } - if ( ! is_null($limit)) { $query .= ' LIMIT ' . $limit; } + if ( ! is_null($offset)) { + $query .= ' OFFSET ' . $offset; + } + return $query; } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php index 2e7e11b9f..5ba808d4d 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php @@ -186,7 +186,7 @@ class MySqlPlatformTest extends \Doctrine\Tests\DbalTestCase public function testModifyLimitQuery() { $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0); - $this->assertEquals('SELECT * FROM user OFFSET 0 LIMIT 10', $sql); + $this->assertEquals('SELECT * FROM user LIMIT 10 OFFSET 0', $sql); } public function testModifyLimitQueryWithEmptyOffset() diff --git a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php index e6f37518f..757cf8c64 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php @@ -212,7 +212,7 @@ class PostgreSqlPlatformTest extends \Doctrine\Tests\DbalTestCase public function testModifyLimitQuery() { $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0); - $this->assertEquals('SELECT * FROM user OFFSET 0 LIMIT 10', $sql); + $this->assertEquals('SELECT * FROM user LIMIT 10 OFFSET 0', $sql); } public function testModifyLimitQueryWithEmptyOffset() diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php index 5bf0a205a..846c81bae 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php @@ -114,7 +114,7 @@ class SqlitePlatformTest extends \Doctrine\Tests\DbalTestCase public function testModifyLimitQuery() { $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0); - $this->assertEquals('SELECT * FROM user OFFSET 0 LIMIT 10', $sql); + $this->assertEquals('SELECT * FROM user LIMIT 10 OFFSET 0', $sql); } public function testModifyLimitQueryWithEmptyOffset() diff --git a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php index 8f909b7c3..ef3069b91 100644 --- a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php @@ -361,7 +361,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase ->setMaxResults(10) ->setFirstResult(0); - $this->assertEquals('SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ OFFSET 0 LIMIT 10', $q->getSql()); + $this->assertEquals('SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ LIMIT 10 OFFSET 0', $q->getSql()); } public function testSizeFunction()