summaryrefslogtreecommitdiff
path: root/it_dbi.class
diff options
context:
space:
mode:
authorUrban Müller2020-04-21 16:08:10 +0200
committerUrban Müller2020-04-21 16:08:10 +0200
commit7e04a37ea0d3989a4347f41ff0e5ea81ac3981d5 (patch)
tree6c371d0980d62b3d21f1690650bebd44f1b1ea1b /it_dbi.class
parent9162e288d0b407ebf4823560c42968b4ab23ee91 (diff)
downloaditools-7e04a37ea0d3989a4347f41ff0e5ea81ac3981d5.tar.gz
itools-7e04a37ea0d3989a4347f41ff0e5ea81ac3981d5.tar.bz2
itools-7e04a37ea0d3989a4347f41ff0e5ea81ac3981d5.zip
dbi: improve docs, enable LIMIT => false
Diffstat (limited to 'it_dbi.class')
-rw-r--r--it_dbi.class21
1 files changed, 12 insertions, 9 deletions
diff --git a/it_dbi.class b/it_dbi.class
index 7c13eec..b06a3ea 100644
--- a/it_dbi.class
+++ b/it_dbi.class
@@ -357,7 +357,8 @@ function _where($params)
}
else if ($field == "LIMIT")
{
- $stringquery .= " LIMIT " . (it::match('^[ ,\d]+$', $value) ?: it::error(['title' => "invalid LIMIT $value", 'body' => $params]) + 0);
+ if ($value !== false) # only false no null; uninitialized values should not unintentionally omit LIMIT
+ $stringquery .= " LIMIT " . (it::match('^[ ,\d]+$', $value) ?: it::error(['title' => "invalid LIMIT $value", 'body' => $params]) + 0);
}
else
{
@@ -617,14 +618,16 @@ function read($id=null)
/**
* Select a set of records from table and fetch the first one
- * @param $query One or more optional arrays of (field => value) or sqlstring pairs. Defaults to null (select all records)
- * Fields will be joined by AND
- * Fields can contain a compare operator: 'name LIKE' => "j%" or 'amount >' => 100
- * Fields can start with - to prevent quoting of right side: '-modified' => "CURDATE()"
- * $query can contain magic field 'SELECT' for things like 'COUNT(*)' or 'DISTINCT foo', defaults to '*'
- * $query can contain magic field 'FROM' or 'JOIN' for things like 'tableA LEFT JOIN tableB ON a=b', defaults to table name
- * $query can contain 'CALC_FOUND_ROWS', if true member var _found_rows contains number of matching rows before LIMIT
- * $query can contain 'NOFETCH', if true the first row is not prefetched (e.g. when directly using _result)
+ * @param $query Vararg. Arrays of (field => value) pairs or plain string query parts. Default: Select all
+ * Fields will be joined by AND
+ * Fields can contain a compare operator: 'name LIKE' => "j%" or 'amount >' => 100
+ * Fields can start with - to prevent quoting of right side: '-modified' => "CURDATE()"
+ * @param $query['SELECT'] expression to be returned, e.g. 'SELECT' => 'DISTINCT foo'. defaults to '*'
+ * @param $query['FROM'] table names to use for joins, e.g. 'FROM' => 'tableA LEFT JOIN tableB ON a=b'
+ * @param $query['JOIN'] like 'FROM'
+ * @param $query['CALC_FOUND_ROWS'] if true, if true member var _found_rows contains number of matching rows before LIMIT
+ * @param $query['LIMIT'] max number of rows to return; false for no limit
+ * @param $query['NOFETCH'] if true the first row is not prefetched (e.g. when directly using _result)
* @return Number of matching rows, use iterate() to fetch the next record
* @see iterate()
* @see _where()