diff options
author | Nathan Gass | 2020-09-03 15:52:06 +0200 |
---|---|---|
committer | Nathan Gass | 2020-09-03 15:52:06 +0200 |
commit | d3f0a6e4f822607b41d138afaa77081cab6afe5e (patch) | |
tree | c592e1e7b5101e77e8b3ca8b20f5d8d286b5a903 /it_dbi.class | |
parent | 0a1feb7c54e7167b0479fe116e0062017d9496b8 (diff) | |
download | itools-d3f0a6e4f822607b41d138afaa77081cab6afe5e.tar.gz itools-d3f0a6e4f822607b41d138afaa77081cab6afe5e.tar.bz2 itools-d3f0a6e4f822607b41d138afaa77081cab6afe5e.zip |
avoid arrow functions as we support php 7.0
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) |