I have problem with my code when i\'m trying to save multiple data into database at the same time, this is my code to save into database:
foreach ($data as $
You can use Yes It Is Batch Insert to insert multiple rows. It is faster than any of the ways stated here :
$connection->createCommand()->batchInsert('table_name', ['table_column_1', 'table_column_2'], [
['column_1_data_a', 'column_2_data_a'],
['column_1_data_b', 'column_2_data_b'],
['column_1_data_c', 'column_2_data_c'],
])->execute();
Check the link for this.