Insert batch in Laravel 5

2019-09-18 20:58发布

I am using laravel 5. I have tried to insert the following data in laravel using Insert. But not working anymore.

I have $permission array which contains the following array detials.

Array
(
[0] => Array
    (
        [permission_id] => 1
        [role_id] => 1
    )

[1] => Array
    (
        [permission_id] => 2
        [role_id] => 1
    )

[2] => Array
    (
        [permission_id] => 3
        [role_id] => 1
    )

[3] => Array
    (
        [permission_id] => 4
        [role_id] => 1
    )
)

DB::table('permission_role')->insert($permission)

1条回答
Emotional °昔
2楼-- · 2019-09-18 21:29
array
(
    array
    (
        [permission_id] => 1,
        [role_id] => 1,
    ),

    array
    (
        [permission_id] => 2,
        [role_id] => 1,
    ),
    array
    (
        [permission_id] => 3,
        [role_id] => 1,
    ),
    array
    (
        [permission_id] => 4,
        [role_id] => 1,
    )
)
查看更多
登录 后发表回答