colshrapnel/safemysql — pull request #21 by ExplodingCabbage (2014-04-21 21:52:18+00:00)
Title: Documentation improvements plus adding new placeholders for multi-row INSERT queries

Good evening, Colonel.

Something that came up at work recently: SafeMySQL doesn't currently offer a convenient way to INSERT multiple rows in a single query. You can insert them in a loop with one query per row, of course, but that potentially incurs an intolerable performance hit for large numbers of rows going into a large table over a connection with non-zero latency.

My proposed solution is the new `?m` and `?k` placeholders that take an array of rows to insert - either as sequential 'list-like' arrays, or associative 'dictionary-like' arrays - for use in `INSERT... VALUES.,.` queries. I've also added a `filter2DArray` method for use of arrays of dictionaries, that calls `filterArray` on each dictionary in the list - this allows the same convenient whitelisting that `filterArray` provides to be used for bulk inserts.

As a native English speaker, I've also cast my eye over the documentation (both in README.md and the comments in safemysql.class.php) and tried to fix things that were unclear or used incorrect English. With a couple of exceptions, I've tried to stay faithful to the original text and just tweak the wording for clarity.

I hope you approve!

Cabbage