From adadae917b981ec4cccc29951a0bf22edb8fe380 Mon Sep 17 00:00:00 2001 From: David Flatz Date: Fri, 5 Oct 2018 15:49:10 +0200 Subject: fix addition of dynamic columns to record where dyncols is NULL --- it_dbi.class | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'it_dbi.class') diff --git a/it_dbi.class b/it_dbi.class index cee004a..d9688cd 100644 --- a/it_dbi.class +++ b/it_dbi.class @@ -281,7 +281,7 @@ function _set($tags, $force = false) if ($force == "insert") # INSERT/REPLACE $result[] = "dyncols = JSON_OBJECT(" . join(", ", (array)$alldyns) . ")"; else if ($newdyns) - $result[] = "dyncols = JSON_SET(dyncols, " . join(", ", $newdyns) .")"; + $result[] = "dyncols = JSON_SET(" . ($this->_dyndata ? 'dyncols' : '"{}"') . ", " . join(", ", $newdyns) .")"; } $this->_writes += $result ? 1 : 0; @@ -682,7 +682,7 @@ function iterate() foreach ((array)$this->_dyndata as $field => $dummy) unset($this->$field); - foreach (($t = $this->_data['dyncols']) ? ($this->_dyndata = (array)json_decode($t, true)) : [] as $field => $value) + foreach (($this->_dyndata = ($t = $this->_data['dyncols']) ? (array)json_decode($t, true) : []) as $field => $value) $this->_data[$field] = $value; unset($this->_data['dyncols']); -- cgit v1.2.3