Open
Description
I'm trying to use manual commit / rollback with a MySQL connection pool, but I can't find a reasonable way to send the "COMMIT" / "ROLLBACK" statements to all used connections in the pool.
auto connPool = new MySQLPool("...");
connPool.onNewConnection = delegate(conn){
conn.exec("SET autocommit=0");
};
// Lock several connections and send transactions
// [...]
// I'd like to do something like this:
writeln("Apply transactions? (y/n)");
if(readln() == "y\n")
connPool.execAll("COMMIT");
else
connPool.execAll("ROLLBACK");
// or this:
if(readln() == "y\n")
foreach(ref conn ; connPool.connections)
conn.exec("COMMIT");
else
foreach(ref conn ; connPool.connections)
conn.exec("ROLLBACK");
Is there something I'm missing?
I'm willing to send you a PR if we agree on a simple solution ;)