Doctrine - insert multiple rows with just one save()
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.
Here another solution ,tested on Doctrine 1.2. No need to save each records, the flush() automatically finds out all the unsaved instances and saves them all.
$row = new \My_Doctrine_Record();$row->name = 'aaa';$row->approved = 1;/// ...$row = new \My_Doctrine_Record();$row->name = 'val';$row->approved = 'bbb';Doctrine_Manager::connection()->flush();