mirror of
https://github.com/dg/dibi.git
synced 2025-08-04 13:17:58 +02:00
This commit is contained in:
committed by
David Grudl
parent
9189d56c05
commit
d6826d62ed
@@ -542,17 +542,23 @@ final class DibiTranslator extends DibiObject
|
|||||||
return '';
|
return '';
|
||||||
|
|
||||||
} elseif ($mod === 'lmt') { // apply limit
|
} elseif ($mod === 'lmt') { // apply limit
|
||||||
if ($this->args[$cursor] !== NULL) {
|
$arg = $this->args[$cursor++];
|
||||||
$this->limit = (int) $this->args[$cursor];
|
if ($arg === NULL) {
|
||||||
|
} elseif ($this->comment) {
|
||||||
|
return "(limit $arg)";
|
||||||
|
} else {
|
||||||
|
$this->limit = (int) $arg;
|
||||||
}
|
}
|
||||||
$cursor++;
|
|
||||||
return '';
|
return '';
|
||||||
|
|
||||||
} elseif ($mod === 'ofs') { // apply offset
|
} elseif ($mod === 'ofs') { // apply offset
|
||||||
if ($this->args[$cursor] !== NULL) {
|
$arg = $this->args[$cursor++];
|
||||||
$this->offset = (int) $this->args[$cursor];
|
if ($arg === NULL) {
|
||||||
|
} elseif ($this->comment) {
|
||||||
|
return "(offset $arg)";
|
||||||
|
} else {
|
||||||
|
$this->offset = (int) $arg;
|
||||||
}
|
}
|
||||||
$cursor++;
|
|
||||||
return '';
|
return '';
|
||||||
|
|
||||||
} else { // default processing
|
} else { // default processing
|
||||||
|
@@ -74,3 +74,15 @@ WHERE
|
|||||||
%if', FALSE, 'AND [admin]=1 %end
|
%if', FALSE, 'AND [admin]=1 %end
|
||||||
%else 1 LIMIT 10 %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'
|
||||||
|
));
|
||||||
|
Reference in New Issue
Block a user