mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MINOR: Always store SQLQuery::$limit as a 2-element array internally.
This commit is contained in:
parent
199e267bbf
commit
8a9903988f
@ -186,12 +186,28 @@ class SQLQuery {
|
||||
|
||||
/**
|
||||
* Pass LIMIT clause either as SQL snippet or in array format.
|
||||
* Internally, limit will always be stored as a map containing the keys 'start' and 'limit'
|
||||
*
|
||||
* @param string|array $limit
|
||||
* @return SQLQuery This instance
|
||||
*/
|
||||
public function limit($limit) {
|
||||
$this->limit = $limit;
|
||||
if($limit && is_numeric($limit)) {
|
||||
$this->limit = array(
|
||||
'start' => 0,
|
||||
'limit' => $limit,
|
||||
);
|
||||
} else if($limit && is_string($limit)) {
|
||||
if(strpos($limit,',') !== false) list($start, $innerLimit) = explode(',', $limit, 2);
|
||||
else list($innerLimit, $start) = explode(' OFFSET ', strtoupper($limit), 2);
|
||||
$this->limit = array(
|
||||
'start' => trim($start),
|
||||
'limit' => trim($innerLimit),
|
||||
);
|
||||
|
||||
} else {
|
||||
$this->limit = $limit;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user