Skip to content
Browse files

[Platform] Store columns added to do the limit on Oracle.

  • Loading branch information...
1 parent 6470e20 commit b9423c8d46a2bcdaa5a1f0b26a9a28259b1e44a2 @benja-M-1 committed Aug 17, 2012
View
16 lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
@@ -115,6 +115,14 @@
protected $_keywords;
/**
+ * Holds extra columns added for
+ * queries specifcally for the platform.
+ *
+ * @var array
+ */
+ protected $doctrineExtraColumns = array();
+
+ /**
* Constructor.
*/
public function __construct() {}
@@ -2851,4 +2859,12 @@ protected function getReservedKeywordsClass()
{
throw DBALException::notSupported(__METHOD__);
}
+
+ /**
+ * @return array
+ */
+ public function getDoctrineExtraColumns()
+ {
+ return $this->doctrineExtraColumns;
+ }
}
View
5 lib/Doctrine/DBAL/Platforms/OraclePlatform.php
@@ -644,6 +644,7 @@ protected function doModifyLimitQuery($query, $limit, $offset = null)
{
$limit = (int) $limit;
$offset = (int) $offset;
+ $rownumAlias = 'doctrine_rownum';
if (preg_match('/^\s*SELECT/i', $query)) {
if (!preg_match('/\sFROM\s/i', $query)) {
@@ -654,7 +655,7 @@ protected function doModifyLimitQuery($query, $limit, $offset = null)
$column = '*';
if ($offset > 0) {
$min = $offset + 1;
- $query = 'SELECT * FROM (SELECT a.' . $column . ', rownum AS doctrine_rownum FROM (' .
+ $query = 'SELECT * FROM (SELECT a.' . $column . ', rownum AS ' . $rownumAlias . ' FROM (' .
$query .
') a WHERE rownum <= ' . $max . ') WHERE doctrine_rownum >= ' . $min;
} else {
@@ -663,6 +664,8 @@ protected function doModifyLimitQuery($query, $limit, $offset = null)
}
}
+ $this->doctrineExtraColumns[] = $rownumAlias;
+
return $query;
}

0 comments on commit b9423c8

Please sign in to comment.
Something went wrong with that request. Please try again.