Insert multiples objects without foreach

I need to improve the performance of my system, I have an array of objects and I need to insert it in a single process, can anything be done with the ORM of yii2?

From a query it would be something like that:

INSERT INTO MyTable
  ( Column1, Column2, Column3 )
VALUES
  ('John', 123, 'Lloyds Office'), 
  ('Jane', 124, 'Lloyds Office'), 
  ('Billy', 125, 'London Office'),
  ('Miranda', 126, 'Bristol Office');

Can be done by BatchInsert()

1 Like

Thanks for the answer, batch insert requires an array, my question is if I can use multiple objects, without converting these to an array.