dracony/PHPixie-DB — pull request #1 by SergeantHawke (2013-12-24 05:24:24+00:00)
Title: Added support for batch inserts

I may have missed something obvious, but this feature didn't seem to be there and it'd be useful to me for something I'm doing in PHPixie, so I've implemented it.

Suppose you have a table called "fairies" and you want to add Tinkerbell and Trixie. Previously it'd be necessary to run several queries for this.

With batch inserts, it is possible to do it all in one query:

$this->pixie->db->query('insert')->table('fairies')
->data(array(array('name' => 'Tinkerbell'), array('name' => 'Trixie')))
->execute();

There's probably a more robust and elegant way to determine if the data is an array of arrays and do all the work of getting the values, but my implementation works for what I need it for.