Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doctrine - insert multiple rows with just one save()

Tags:

How do I insert multiple rows into table calling save() method once in Doctrine?

like image 830
Almas Adilbek Avatar asked Mar 24 '11 06:03

Almas Adilbek


1 Answers

Add each record to a Doctrine_Collection the call save() on the collection object.

$collection = new Doctrine_Collection('tablename'); $collection->add($record1); $collection->add($record2); $collection->add($record3); $collection->add($record4); $collection->save(); 

This only works if all the records are for the same table. Otherwise you're out of luck.

like image 65
xzyfer Avatar answered Sep 30 '22 18:09

xzyfer