This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

doctrine multiple insert

Discussion specific to symfony 1.1.x stable

doctrine multiple insert

by zf_coder » Thu Aug 28, 2008 12:21 am

Is there any way to create a multiple insert query with Doctrine?
zf_coder
Junior Member
 
Posts: 4
Joined: Mon May 26, 2008 4:52 pm
Location: afsa

Re: doctrine multiple insert

by Vadim » Wed Jan 13, 2010 11:26 am

Yeah, I've got the same question! Quite a few of info about this in Internets...
Vadim
Junior Member
 
Posts: 20
Joined: Thu Oct 23, 2008 11:51 am

Re: doctrine multiple insert

by guyaloni » Wed Jun 09, 2010 10:30 am

I was looking for a solution for quite a while, and couldn't find any.

My problem is that I have a very long array with items to either update or insert, so I would like to generate a multiple REPLACE query.

At the moment I do:
Code: Select all
foreach ($info as $infoElement) {
    $o = new globalNews();
    $o->setInfoId($infoElement->id);;
       :
       :
    $o->replace();
}


However, this code might generate many queries (even hundreds!), instead of one.

I am sure there is a solution, somebody can help??? :?~ :-?~ :???:
User avatar
guyaloni
Member
 
Posts: 84
Joined: Fri May 21, 2010 12:49 pm
Location: Spain

Re: doctrine multiple insert

by halfer » Wed Jun 09, 2010 12:10 pm

The Doctrine manual mentions "bulk-insert in MySQL" so I think it would do. Check the manual, or ask on their mailing list.
halfer
Faithful Member
 
Posts: 10148
Joined: Mon Jan 30, 2006 1:16 pm
Location: West Midlands, UK