S
S
suhuxa12017-07-13 11:05:47
Laravel
suhuxa1, 2017-07-13 11:05:47

How to perform multiple data insert in laravel?

Good afternoon!
I'm learning Laravel and I need to add 1000 rows to a table. I know that you can add a loop like this:

$class->insert([
                    'name'  =>  $val['one'],
                    'surname'      =>  $val['two']
            ]);

But in my opinion it is inappropriate to send 1000 queries to the database when you can execute 1 query, which will contain 1000 data. I know how to do it on bare Sql through insert. But how to do this with fluent or what is the name of this laravel expression builder? Is there such a possibility at all?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2017-07-13
@suhuxa1

https://stackoverflow.com/a/13595393

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question