Inserting 100 records into a table inside a loop.I have database table called emp_table with 100
employees records
if you want to insert this records into a new table called salary_table in this cas see how the batch
insert works in laravel
1 2 3 4 5 6 7 8 9 10 11 |
$new_insert_array=array(); foreach($emp_details as $key=>$val) { $new_insert_array[]=array('emp_id'=>$emp_details['emp_id'],'emp_name'=>$emp_details['emp_name'],'basic_ sal'=>$emp_details['basic_sal']); //no need to use insert statement here because this will execute 100 times so keep the code outside the loop } Salary::insert($new_insert_array); ?> |