3

I have products feeds and want to insert it in one query in ZF2. Is there any feature in ZF2 that make it easier?

My Blog : http://programming-tips.in

Arvind
  • 938
  • 9
  • 23
  • This may possibly help you out: http://stackoverflow.com/questions/13831582/how-does-zend-db-in-zf2-control-transactions – Sam Mar 25 '13 at 08:29
  • Actually I have an array $products = array(0 => array(----),1 => array(----),....).I am looking for that is there any function in ZF2 which can take this array as input and insert into database at once.Right now I can run a loop and insert each record one by one using $this->insert($product_array); – Arvind Mar 25 '13 at 08:36

1 Answers1

0

In ZF1, to allow this, I extended the Mysql Adapter and added an extendedInsert method.

Of course, the easier route is just to surround your inserts with a transaction/commit as commented above. Shoving multiple inserts through in a single transaction is about the same as doing an extended insert as far as how much time it takes. Plus, you should be able to use a prepared statement and just iterate through your array to insert all the records.

Gordon Forsythe
  • 356
  • 3
  • 7