diff options
-rw-r--r-- | it_dbi.class | 28 |
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) : ''; } /** |