mirror of
https://github.com/silverstripe/silverstripe-postgresql
synced 2024-10-22 17:05:45 +02:00
BUG FIX: Offset/Limit arrays now handled properly
This commit is contained in:
parent
a6b1647a11
commit
b0b0383229
@ -156,6 +156,7 @@ class PostgreSQLDatabase extends Database {
|
||||
$starttime = microtime(true);
|
||||
}
|
||||
|
||||
echo $sql . "<br><br>\n\n";
|
||||
$handle = pg_query($this->dbConn, $sql);
|
||||
|
||||
if(isset($_REQUEST['showqueries'])) {
|
||||
@ -1071,21 +1072,23 @@ class PostgreSQLDatabase extends Database {
|
||||
if($sqlQuery->having) $text .= " HAVING ( " . implode(" ) AND ( ", $sqlQuery->having) . " )";
|
||||
if($sqlQuery->orderby) $text .= " ORDER BY " . $sqlQuery->orderby;
|
||||
|
||||
echo 'limit: <pre>';
|
||||
print_r($sqlQuery->limit);
|
||||
echo '</pre>';
|
||||
echo 'order by:<pre>';
|
||||
print_r($sqlQuery->orderby);
|
||||
echo '</pre>';
|
||||
|
||||
if($sqlQuery->limit) {
|
||||
$limit = $sqlQuery->limit;
|
||||
// Pass limit as array or SQL string value
|
||||
if(is_array($limit)) {
|
||||
if(!array_key_exists('limit',$limit)) user_error('SQLQuery::limit(): Wrong format for $limit', E_USER_ERROR);
|
||||
|
||||
if(isset($limit['start']) && is_numeric($limit['start']) && isset($limit['limit']) && is_numeric($limit['limit'])) {
|
||||
$combinedLimit = (int)$limit['start'] . ',' . (int)$limit['limit'];
|
||||
} elseif(isset($limit['limit']) && is_numeric($limit['limit'])) {
|
||||
$combinedLimit = (int)$limit['limit'];
|
||||
} else {
|
||||
$combinedLimit = false;
|
||||
}
|
||||
if(!empty($combinedLimit)) $this->limit = $combinedLimit;
|
||||
|
||||
|
||||
if(isset($limit['start']))
|
||||
$text.=' OFFSET ' . $limit['start'];
|
||||
if(isset($limit['limit']))
|
||||
$text.=' LIMIT ' . $limit['limit'];
|
||||
|
||||
} else {
|
||||
if(strpos($sqlQuery->limit, ',')){
|
||||
$limit=str_replace(',', ' LIMIT ', $sqlQuery->limit);
|
||||
|
Loading…
Reference in New Issue
Block a user