samedi 21 mai 2016

Bulk Insert instead of foreach loop: Laravel 5.2.31

I am using the following code to insert the records One by One.

foreach($data["SportsTypes"] as $SportsTypeID) {
    $userSportsType = new \App\Models\User\UserSportsTypeModel();
    $userSportsType->UserID       = 1;
    $userSportsType->SportsTypeID = $SportsTypeID;
    $userSportsType->save();
}

Can I do bulk insert so as to get rid of saving process in iteration?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1WIbho1
via IFTTT

Aucun commentaire:

Enregistrer un commentaire