[ticket/11469] Add SQL insert buffer allowing easier handling of multi inserts.

1. Tries to prevent going over max packet size by flushing to the database
   after a certain number of rows have been added.
2. Because of 1., it is less likely to reach a connection timeout when
   inserting a huge number of rows.
3. By flushing the buffer when a certain size is reached, memory usage should
   be lower compared to building the whole insert row set first.

PHPBB3-11469