summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Gass2021-01-06 17:39:41 +0100
committerNathan Gass2021-01-06 17:39:41 +0100
commit3bc45983207d43f9c80ef08e2ef28064f57e19e9 (patch)
treee29e8498ddcdfc0987887eedbd47da68fcdadd90
parentbdb59ae566c1b4c78a4d82a881f8b1ffbf6dbbef (diff)
downloaditools-3bc45983207d43f9c80ef08e2ef28064f57e19e9.tar.gz
itools-3bc45983207d43f9c80ef08e2ef28064f57e19e9.tar.bz2
itools-3bc45983207d43f9c80ef08e2ef28064f57e19e9.zip
add special handling of numeric keys to _set and _values consistent with _where
-rw-r--r--it_dbi.class28
1 files changed, 21 insertions, 7 deletions
diff --git a/it_dbi.class b/it_dbi.class
index e51b23e..ace10ba 100644
--- a/it_dbi.class
+++ b/it_dbi.class
@@ -248,6 +248,11 @@ function _expressions($tags, $force = false)
foreach((array)$tags as $field => $value)
{
+ if (is_int($field)) { /* no key specified; pass on unchanged */
+ $result[$field] = $value;
+ continue;
+ }
+
$f = trim($field, "-");
if (!$this->_fields[$f] && it::match(",$f,", $this->_fieldnames))
it::error("case mismatch on field $f, valid fields $this->_fieldnames");
@@ -305,10 +310,15 @@ function _expressions($tags, $force = false)
function _set($tags, $force = false)
{
$expressions = $this->_expressions($tags, $force);
- foreach ((array)$expressions as $k => $v)
- $strings[] = $this->escape_name($k) . "=$v";
+ $append = [];
+ foreach ((array)$expressions as $k => $v) {
+ if (is_int($k)) /* no key specified; just append */
+ $append[] = $v;
+ else
+ $strings[] = $this->escape_name($k) . "=$v";
+ }
- return $strings ? 'SET ' . implode(', ', $strings) : '';
+ return $strings ? 'SET ' . implode(', ', $strings) . implode(' ', $append) : '';
}
/**
@@ -318,12 +328,16 @@ function _set($tags, $force = false)
function _values($tags, $force = false)
{
$expressions = $this->_expressions($tags, $force);
-
+ $append = [];
foreach ((array)$expressions as $k => $v) {
- $keys[] = $this->escape_name($k);
- $vals[] = $v;
+ if (is_int($k)) /* no key specified; just append */
+ $append[] = $v;
+ else {
+ $keys[] = $this->escape_name($k);
+ $vals[] = $v;
+ }
}
- return $expressions ? '(' . implode(', ', $keys) . ') VALUES (' . implode(', ', $vals) . ')' : '';
+ return $expressions ? '(' . implode(', ', $keys) . ') VALUES (' . implode(', ', $vals) . ')' . implode(' ', $append) : '';
}
/**