Jump to:

3460 Posts in 1064 Topics by 739 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Adding multiple dataobjects with many_many_extraFields to componentset

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

Page: 1
Go to End
Author Topic: 630 Views
  • alexyoungs
    Avatar
    Community Member
    5 Posts

    Adding multiple dataobjects with many_many_extraFields to componentset Link to this post

    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?

    Cheers!

  • alexyoungs
    Avatar
    Community Member
    5 Posts

    Re: Adding multiple dataobjects with many_many_extraFields to componentset Link to this post

    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 ...

    630 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.