mirror of
https://github.com/dg/dibi.git
synced 2025-02-23 10:26:21 +01:00
This commit is contained in:
parent
9189d56c05
commit
d6826d62ed
@ -542,17 +542,23 @@ final class DibiTranslator extends DibiObject
|
||||
return '';
|
||||
|
||||
} elseif ($mod === 'lmt') { // apply limit
|
||||
if ($this->args[$cursor] !== NULL) {
|
||||
$this->limit = (int) $this->args[$cursor];
|
||||
$arg = $this->args[$cursor++];
|
||||
if ($arg === NULL) {
|
||||
} elseif ($this->comment) {
|
||||
return "(limit $arg)";
|
||||
} else {
|
||||
$this->limit = (int) $arg;
|
||||
}
|
||||
$cursor++;
|
||||
return '';
|
||||
|
||||
} elseif ($mod === 'ofs') { // apply offset
|
||||
if ($this->args[$cursor] !== NULL) {
|
||||
$this->offset = (int) $this->args[$cursor];
|
||||
$arg = $this->args[$cursor++];
|
||||
if ($arg === NULL) {
|
||||
} elseif ($this->comment) {
|
||||
return "(offset $arg)";
|
||||
} else {
|
||||
$this->offset = (int) $arg;
|
||||
}
|
||||
$cursor++;
|
||||
return '';
|
||||
|
||||
} else { // default processing
|
||||
|
@ -74,3 +74,15 @@ WHERE
|
||||
%if', FALSE, 'AND [admin]=1 %end
|
||||
%else 1 LIMIT 10 %end'
|
||||
));
|
||||
|
||||
|
||||
// limit & offset
|
||||
Assert::same(
|
||||
'SELECT * FROM foo /* (limit 3) (offset 5) */',
|
||||
$conn->translate(
|
||||
'SELECT * FROM foo',
|
||||
'%if', FALSE,
|
||||
'%lmt', 3,
|
||||
'%ofs', 5,
|
||||
'%end'
|
||||
));
|
||||
|
Loading…
x
Reference in New Issue
Block a user