phoenixwizard phoenixwizard - 1 year ago 148
PHP Question

Bulk Insertion in Laravel using eloquent ORM

How can we perform bulk database insertions in Laravel using Eloquent ORM?

I want to accomplish this in Laravel:
but I am getting the following error.

SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters.

Answer Source

You can just use Eloquent::insert().

For example:

$data = array(
    array('name'=>'Coder 1', 'rep'=>'4096'),
    array('name'=>'Coder 2', 'rep'=>'2048'),

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download