Acrux-DBI
view release on metacpan or search on metacpan
lib/Acrux/DBI.pm view on Meta::CPAN
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
See C<LICENSE> file and L<https://dev.perl.org/licenses/>
=cut
our $VERSION = '0.03';
use Carp qw/carp croak/;
use Scalar::Util 'weaken';
use DBI qw//;
use Mojo::Util qw/monkey_patch md5_sum/;
use Mojo::URL qw//;
use Mojo::Cache;
use Acrux::Util qw//;
use Acrux::RefUtil qw/is_array_ref is_code_ref/;
use Acrux::DBI::Res;
use Acrux::DBI::Tx;
use Acrux::DBI::Dump;
lib/Acrux/DBI.pm view on Meta::CPAN
my $self = shift;
return 0 unless $self->{dsn};
return 0 unless my $dbh = $self->dbh;
return 0 unless $dbh->can('ping');
return $dbh->ping();
}
# Transaction methods
sub transaction {
my $tx = Acrux::DBI::Tx->new(dbi => shift);
weaken $tx->{dbi};
return $tx;
}
sub begin {
my $self = shift;
return unless my $dbh = $self->dbh;
$dbh->begin_work;
return $self;
}
sub commit {
my $self = shift;
lib/Acrux/DBI/Tx.pm view on Meta::CPAN
This is a scope guard for L<Acrux::DBI> transactions
=head1 ATTRIBUTES
This class implements the following attributes
=head2 dbi
dbi => $dbi
The object this transaction belongs to. Note that this attribute is weakened
=head1 METHODS
This class implements the following methods
=head2 commit
$tx->commit;
Commit transaction.
( run in 0.244 second using v1.01-cache-2.11-cpan-65fba6d93b7 )