Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Adding multiple dataobjects with many_many_extraFields to componentset

Go to End

2 Posts   995 Views


Community Member, 5 Posts

11 December 2011 at 4:20am

Edited: 11/12/2011 4:27am

Hi all,

I'm trying to figure out the most efficient way of adding multiple dataobjects to a componentset - addMany() would work perfectly except there doesn't seem to be the option of including many_many_extraFields data along with the ID array.

Does anyone know of any way this can be done without having to loop through each dataobject and use add()? I'm looking to loop across thousands of records at a time, so efficiency is the most important factor here.

I suppose a batch insert with addMany() could be followed by some sort of batch update, if such a thing exists?



Community Member, 5 Posts

11 December 2011 at 6:44am

So it seems after a bit of digging through Sapphire's core, addMany() is simply a shorthand foreach add() loop, so probably won't help efficiency much.

Perhaps looping through each dataobject and building a manual SQL command to execute at the end of the loop is the simplest answer here ...