How to Create a Incremental Array to Make a Bulk Insert on Query Builder

Posted 1 year ago by berinjelablues

I need to do something like the example below but I do not know how to add the field to the array.

                        $column_count = 0;
                        foreach ($line as $column) {

                            $array_line[$column_count] = $field_names[$column_count] => $column;
                            $column_count++;
                        }
                        DB::table('table')->insert($array_line);

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.