NAME
DBIx::Poggy::DBI - DBI subclass
DESCRIPTION
Overrides several methods in DBI. All queries are marked as async. See list of supported methods below:
METHODS
supported
These are supported: "selectrow_array" in DBI, "selectrow_arrayref" in DBI, "selectrow_hashref" in DBI, "selectall_arrayref" in DBI, "selectall_hashref" in DBI and "do" in DBI.
For example:
$pool->take->selectrow_array(
"SELECT * FROM test LIMIT 1",
)->then(sub {
my @row = @_;
...
});
See "Transactions" to learn about "begin_work", "commit" and "rollback".
not supported
These are not supported, but will be when I need them or somebody will write a patch: "selectcol_arrayref" in DBI
You don't use prepare
, bind*
, execute
or fetch*
. I have some ideas of making these work, but don't think there is urgent need to pursue.
Transactions
This module wraps "begin_work", "commit" and "rollback" methods to help handle transactions.
NOTE that flow is similar to sync DBI: begin, query, query, ..., commit or rollback, so it's your job to make sure commit or rollback is called after all queries on the handle are finished otherwise code dies.
begin_work
Returns a Promise that will be resolved once transaction is committed or rejected if the transaction is rolled back or failed attempt to start the transaction.
Value of the promise would be whatever is passed to commit or rollback.
commit
Takes resolution value of the transaction, commits and resolves the promise returned by "begin_work" with the value.
Dies if you call commit without transaction or while queries are active.
rollback
Takes rollback value of the transaction, commits and rejects the promise returned by "begin_work" with the value.
Dies if you call rollback without transaction or while queries are active.