if ($type == 'insert') { $fields = $values = []; foreach ($data as $key => $value) { // 键值存入$fields $fields[] = $key; // 值存入$values; $values[] = $value; } }
The foreach you wrote is $key=>$value, and $val is used for assignment below. This is definitely wrong.
The foreach you wrote is $key=>$value, and $val is used for assignment below. This is definitely wrong.