summaryrefslogtreecommitdiff
path: root/framework/Data
diff options
context:
space:
mode:
authorChristophe.Boulain <>2009-05-11 08:48:37 +0000
committerChristophe.Boulain <>2009-05-11 08:48:37 +0000
commit0269b09a498c0d5c98ba4cd9690827f65bb2d1b4 (patch)
tree912ddf16509bd08c49097c023f56447fe5cae1a7 /framework/Data
parentf18f3e606b2c1b8e7de3def314b79bb7f2c69830 (diff)
Fixed Issue#148
Diffstat (limited to 'framework/Data')
-rw-r--r--framework/Data/Common/Oracle/TOracleCommandBuilder.php41
1 files changed, 15 insertions, 26 deletions
diff --git a/framework/Data/Common/Oracle/TOracleCommandBuilder.php b/framework/Data/Common/Oracle/TOracleCommandBuilder.php
index 8c60751a..a22c0f08 100644
--- a/framework/Data/Common/Oracle/TOracleCommandBuilder.php
+++ b/framework/Data/Common/Oracle/TOracleCommandBuilder.php
@@ -86,20 +86,14 @@ class TOracleCommandBuilder extends TDbCommandBuilder {
$niniDoSelect = strpos($sql, 'SELECT') + 6;
$nfimDoSelect = (strpos($sql, 'FROM') !== false ? strpos($sql, 'FROM') : $nfimDaSQL);
- $niniDoWhere = strpos($sql, 'WHERE') + 5;
-
- $WhereConstraint = substr($sql, $niniDoWhere, $nfimDoWhere - $niniDoWhere);
-
- $WhereInSubSelect = "";
- if (trim($WhereConstraint) !== "") {
- $WhereInSubSelect = "WHERE " . $WhereConstraint;
- }
+ $WhereInSubSelect="";
+ if(strpos($sql, 'WHERE')!==false)
+ $WhereInSubSelect = "WHERE " .substr($sql, strpos($sql, 'WHERE')+5, $nfimDoWhere - $niniDoWhere);
$sORDERBY = '';
if (stripos($sql, 'ORDER') !== false) {
$p = stripos($sql, 'ORDER');
- $sORDERBY = substr($sql, $p +8, 10000);
-
+ $sORDERBY = substr($sql, $p +8);
}
$fields = substr($sql, 0, $nfimDoSelect);
@@ -142,23 +136,18 @@ class TOracleCommandBuilder extends TDbCommandBuilder {
") WHERE {$pradoNUMLIN} >= {$offset} ";
************************* */
- $toReg = $offset + $limit -1;
+ $offset=(int)$offset;
+ $toReg = $offset + $limit ;
$fullTableName = $this->getTableInfo()->getTableFullName();
- if (empty ($sORDERBY)) {
- $newSql = " SELECT $fields FROM " .
- "( " .
- " SELECT ROW_NUMBER() OVER ( ORDER BY ROWNUM ) as {$pradoNUMLIN} {$aliasedFields} " .
- " FROM {$fullTableName} {$fieldsALIAS}" .
- ") nn " .
- " WHERE nn.{$pradoNUMLIN} >= {$offset} AND nn.{$pradoNUMLIN} <= {$toReg} ";
- } else {
- $newSql = " SELECT $fields FROM " .
- "( " .
- " SELECT ROW_NUMBER() OVER ( ORDER BY {$sORDERBY} ) as {$pradoNUMLIN} {$aliasedFields} " .
- " FROM {$fullTableName} {$fieldsALIAS} $WhereInSubSelect" .
- ") nn " .
- " WHERE nn.{$pradoNUMLIN} >= {$offset} AND nn.{$pradoNUMLIN} <= {$toReg} ";
- }
+ if (empty ($sORDERBY))
+ $sORDERBY="ROWNUM";
+
+ $newSql = " SELECT $fields FROM " .
+ "( " .
+ " SELECT ROW_NUMBER() OVER ( ORDER BY {$sORDERBY} ) -1 as {$pradoNUMLIN} {$aliasedFields} " .
+ " FROM {$fullTableName} {$fieldsALIAS} $WhereInSubSelect" .
+ ") nn " .
+ " WHERE nn.{$pradoNUMLIN} >= {$offset} AND nn.{$pradoNUMLIN} < {$toReg} ";
//echo $newSql."\n<br>\n";
return $newSql;
}