diff options
Diffstat (limited to 'it_dbi.class')
-rw-r--r-- | it_dbi.class | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/it_dbi.class b/it_dbi.class index ee6ce08..5d86f12 100644 --- a/it_dbi.class +++ b/it_dbi.class @@ -305,8 +305,10 @@ 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"; - return $expressions ? 'SET ' . implode(', ', it::map(fn ($k, $v) => $this->escape_name($k) . "=$v", $expressions)) : ''; + return $strings ? 'SET ' . implode(', ', $strings) : ''; } /** @@ -317,11 +319,11 @@ function _values($tags, $force = false) { $expressions = $this->_expressions($tags, $force); - $result = ''; - if ($expressions) - $result = '(' . implode(', ', it::map(fn ($k) => $this->escape_name($k), $expressions)) . ') VALUES (' . implode(', ', array_values($expressions)) . ')'; - - return $result; + foreach ((array)$expressions as $k => $v) { + $keys[] = $this->escape_name($k); + $vals[] = $v; + } + return $expressions ? '(' . implode(', ', $keys) . ') VALUES (' . implode(', ', $vals) . ')' : ''; } /** @@ -1138,17 +1140,23 @@ function _json_extract($col, $field) function _json_object($tags) { - return "JSON_OBJECT(" . implode(', ', it::map(fn ($f, $v) => "'$f', $v", (array)$tags)) . ")"; + foreach ((array)$tags as $f => $v) + $strings[] = $this->escape_string($f) . ', ' . $v; + return "JSON_OBJECT(" . implode(', ', $strings) . ")"; } function _json_set($source, $tags) { - return "JSON_SET($source, " . implode(", ", it::map(fn ($f, $v) => "'\$.$f', $v", (array)$tags)) . ')'; + foreach ((array)$tags as $f => $v) + $strings[] = $this->escape_string('$.' . $f) . ', ' . $v; + return "JSON_SET($source, " . implode(", ", $strings) . ')'; } function _json_remove($source, $fields) { - return "JSON_REMOVE($source, " . implode(", ", it::map(fn ($dummy, $f) => "'\$.$f'", (array)$fields)) . ')'; + foreach ((array)$fields as $f) + $strings[] = $this->escape_string('$.' . $f); + return "JSON_REMOVE($source, " . implode(", ", $strings) . ')'; } function _fetch_assoc($res) |