Phil Freo Mon Aug 30 00:00:13 -0400 2010

Subject: Support for multi-row inserts and "insert ignore"?

If you need to create and save hundreds of new objects at once, it can be much more efficient to have one SQL query generated like:
INSERT INTO phone_book VALUES ('John Doe', '555-1212'), ('Peter Doe', '555-2323');

Is there any support (or planned support) for this in phpactiverecord?

Additionally, is there any way to do an "INSERT IGNORE"?


Kien La Mon Aug 30 18:46:56 -0400 2010

No, that's not really on the todo list but if you wanted to implement this and submit a patch that'd be great.

No, to the insert ignore as well.

Phil Freo Mon Aug 30 19:07:43 -0400 2010

Thanks...

I haven't started using this yet, just evaluating it for my needs. Especially the first request (multi-insert) seems highly crucial for performance in many situations.

Jacques Fuentes Tue Aug 31 18:51:13 -0400 2010

This was something i wanted to do at some point, and the code wouldn't be very difficult to do so. If you wanted to help out I could get you started.

Phil Freo Wed Sep 01 00:45:05 -0400 2010

Don't have much time right now (just was passively evaluating frameworks). If I ever do get into using this project I'd be happy to contribute though.

Poyan N Fri Jan 07 09:34:04 -0500 2011

I would also like multi-row inserts, as I think it would enhance performance!

Jaggi noyb Thu Jul 28 09:28:32 -0400 2011

I wanted to accomplish this and had something working but it was very rough and kind of buggy. That was a external implementation but now I'm looking at a proper implementation by changing the source but having a bit of a issue of how to accomplish this and follow active records format.

Suggestions on architecture would be good (built into save function or have a insert_all function). Also processing all the values without adding too much load there. I'm PHP5 certified so wouldn't need baby sitting but would rather submit a patch that got used.

renan henrique constancio Fri Mar 17 10:08:17 -0400 2017

Encotrei uma solução alternativa para varias inserções.

Model::query('insert into table( campos ) values (?), (?)', array( 'valores' , 'valores' ));

Daí basta uma adaptação para cada projeto

espero ter ajudado alguém
:)

(1-7/7)