Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 2 years ago.
0

Hi, after 9 months, you have found a solution?, I wrote a little script but I am completely sure that is very ugly :D

DB::transaction(function() use ($dataKeys, $data) {
	$table = 'table';
	foreach ($data as $row) {
		$rowWithKeys = array_combine($dataKeys, $row);
		DB::insert("SET IDENTITY_INSERT  " . $table . "  ON;insert into  " . $table . "  ([column1], [column2], [column3]) values ('" . $rowWithKeys['column1'] . "', '" . $rowWithKeys['column2'] . "', '" . $rowWithKeys['column3'] . "');SET IDENTITY_INSERT  " . $table . " OFF;");
	}
});
DB::commit();
0

Sign in to participate in this thread!

Eventy

Your banner here too?

EdgarsK edgarsk Joined 17 Jul 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.