Acrux-DBI
view release on metacpan or search on metacpan
lib/Acrux/DBI.pm view on Meta::CPAN
package Acrux::DBI;
use strict;
use utf8;
=encoding utf8
=head1 NAME
Acrux::DBI - Database independent interface for Acrux applications
=head1 SYNOPSIS
use Acrux::DBI;
=head1 DESCRIPTION
Database independent interface for Acrux applications
=head2 new
my $dbi = Acrux::DBI->new( $db_url );
my $dbi = Acrux::DBI->new( $db_url, { ... options ... });
my $dbi = Acrux::DBI->new( $db_url, ... options ...);
Build new Acrux::DBI object
B<Options:>
=over 8
=item autoclean
This options turns on auto disconnecting on DESTROY phase
=back
See also list of default options in L</options>
=head1 METHODS
This class implements the following methods
=head2 begin
$dbi->begin;
# ...
$dbi->commit; # ..or $dbi->rollback
This is a transaction method!
This method marks the starting point for the start of a transaction
$dbi->begin;
$dbi->query('insert into test values (?)', 'Foo');
$dbi->query('insert into test values (?)', 'Bar');
$dbi->commit;
See slso L</transaction>, L</commit>, L</rollback>
=head2 cache
my $cache = $dbi->cache;
Returns the L<Mojo::Cache> object
=head2 cachekey
my $cachekey = $dbi->cachekey;
Returns the key name of the cached connect (See L</connect_cached>)
=head2 cleanup
$dbi = $dbi->cleanup;
This internal method to cleanup database handler
=head2 commit
$dbi->begin;
# ...
$dbi->commit;
This is a transaction method!
This method accepts all changes to the database and marks the end
point for the transaction to complete
See also L</begin>, L</rollback>
=head2 connect
my $dbi = $dbi->connect;
die $dbi->error if $dbi->error;
This method makes a connection to the database
=head2 connect_cached
my $dbi = $dbi->connect_cached;
die $dbi->error if $dbi->error;
This method makes a cached connection to the database. See L<DBI/connect_cached> for details
=head2 database
my $database = $dbi->database;
This method returns the database that will be used for generating the connection DSN
This will be used as L<Mojo::URL/path>
( run in 1.223 second using v1.01-cache-2.11-cpan-5b529ec07f3 )