Skip to content

Commit 2782db4

Browse files
authored
change function insert
add check field null
1 parent ac367f4 commit 2782db4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/LaravelBatch.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,10 @@ public function insert($table, $columns, $values, $batchSize = 500)
150150
foreach ($value as $data)
151151
{
152152
foreach ($data as $key => $item)
153-
$data[$key] = "'" . Helpers::mysql_escape($item) ."'";
153+
{
154+
$item = is_null($item) ? 'NULL' : "'" . Helpers::mysql_escape($item) ."'";
155+
$data[$key] = $item;
156+
}
154157

155158
$valueArray[] = '(' . implode(',', $data) . ')';
156159
}

0 commit comments

Comments
 (0)