Bulk Insertion in Laravel using eloquent ORM
Laravel can bulk insertion using eloquent ORM. Insertion is the very basic feature in all project. When we need to do bulk insertion there is a lot of ways are available in Laravel to do the bulk insertion. Some of the ways to bulk insertion are:
1) By using the Raw query in Laravel.
2) By using eloquent ORM.
Example of using eloquent ORM bulk insertion;
You can just use Eloquent::insert().
$data = array(
array(
'name'=>'Coder 1', 'rep'=>'4096',
'created_at'=>date('Y-m-d H:i:s'),
'modified_at'=> date('Y-m-d H:i:s')
),
array(
'name'=>'Coder 2', 'rep'=>'2048',
'created_at'=>date('Y-m-d H:i:s'),
'modified_at'=> date('Y-m-d H:i:s')
),
//...
);
User::insert($data);
Comments
0 comments
Please Sign in or Create an account to Post Comments