summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--it_dbi.class4
-rwxr-xr-xtest/it_dbi.t5
2 files changed, 9 insertions, 0 deletions
diff --git a/it_dbi.class b/it_dbi.class
index 8cf8d54..7c13eec 100644
--- a/it_dbi.class
+++ b/it_dbi.class
@@ -355,6 +355,10 @@ function _where($params)
else
$sep = ' OR ';
}
+ else if ($field == "LIMIT")
+ {
+ $stringquery .= " LIMIT " . (it::match('^[ ,\d]+$', $value) ?: it::error(['title' => "invalid LIMIT $value", 'body' => $params]) + 0);
+ }
else
{
$needs_where = true;
diff --git a/test/it_dbi.t b/test/it_dbi.t
index 9f43f6e..165861f 100755
--- a/test/it_dbi.t
+++ b/test/it_dbi.t
@@ -348,6 +348,11 @@ $r->update(['key4' => "val4'"]); is($r->_writes, 0); is($r-
$r->update(['key4' => "val4'", 'key5' => "val5'"]); is($r->_writes, 1); is($r->key4, "val4'"); is($r->key5, "val5'");
$r->update(['key4' => "val4'", 'key5' => "val5'"]); is($r->_writes, 1); is($r->key4, "val4'"); is($r->key5, "val5'");
+# Check LIMIT
+$count = $r->select('ID >' => 0, 'ORDER BY ID DESC', 'LIMIT' => 1);
+is($count, 1);
+is($r->ID, 6);
+
# Check if iterator clears dynfields left over from previous record
$r->delete(["WHERE 1"]);
$r->replace(['ID' => 1, 'key1' => "a"]);