i check my query .It insert 1st loop after that insert query turn into update is there anyway how to fix this
$database = New database;
DB::transaction(function () use ($database) {
for ($i=0; $i < 5; $i++) {
database->save();
}
});
here is my transaction picture
Put $database = New database;
inside the for
statement. Because in each loop you need a new database object to do the insertion. Currently, you make an object, then the first loop does the insertion and the reset of loops will update the same object.