Skip to content

Commit a1958bf

Browse files
committed
改进parseData方法
1 parent 9417a60 commit a1958bf

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

library/think/db/Builder.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ protected function parseData(Query $query, $data = [], $fields = [], $bind = [])
113113
$result = [];
114114

115115
foreach ($data as $key => $val) {
116+
if ('*' != $options['field'] && !in_array($key, $fields, true)) {
117+
continue;
118+
}
119+
116120
$item = $this->parseKey($query, $key, true);
117121

118122
if ($val instanceof Expression) {
@@ -129,7 +133,7 @@ protected function parseData(Query $query, $data = [], $fields = [], $bind = [])
129133
list($key, $name) = explode('->', $key);
130134
$item = $this->parseKey($query, $key);
131135
$result[$item] = 'json_set(' . $item . ', \'$.' . $name . '\', ' . $this->parseDataBind($query, $key, $val, $bind) . ')';
132-
} elseif (false === strpos($key, '.') && !in_array($key, $fields, true)) {
136+
} elseif ('*' == $options['field'] && false === strpos($key, '.') && !in_array($key, $fields, true)) {
133137
if ($options['strict']) {
134138
throw new Exception('fields not exists:[' . $key . ']');
135139
}

0 commit comments

Comments
 (0)