3093 Posts in 875 Topics by 654 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1281 Views |
-
Multiple inserts using the DataModel

22 August 2009 at 10:55am
Is there a way to insert multiple records into the database as one query, using the DataModel (without having to write a raw SQL query) ?
For example, at the moment I am doing this:
$member = new Member();
$organization->Name = $data['member_name_0'];
..
$member->write();$member = new Member();
$organization->Name = $data['member_name_1'];
..
$member->write();.. which I'm guessing it would be performing multiple insert queries, but it would be better to do a single insert query for all the records. Hope that makes sense.
Any help appreciated,
Cheers -
Re: Multiple inserts using the DataModel

24 August 2009 at 2:07pm
Are you trying to import a list of members into your database?
There is an abstract class designed for bulk updates of data - at the moment I think it is only subclassed by CsvBulkLoader. This is a good way to import a large amount of data.
However, it will still insert/update on a line by line basis. If the question is performance related, it sounds like you are looking for a way to queue up changes into a single transaction. That would be great, but AFAIK there is no functionality for this at present.
Hamish
-
Re: Multiple inserts using the DataModel

28 August 2009 at 12:47am
If i understood good problem seem, I found solution http://silverstripe.org/data-model-questions/show/267209?showPost=267743
| 1281 Views | ||
|
Page:
1
|
Go to Top |


