DBIx::Wrapper::VerySimple - Simplify use of DBI
0.051
use DBIx::Wrapper::VerySimple; $db = DBIx::Wrapper::VerySimple->new( $dsn, @other_args ); $hashref = $db->FetchHash($sql, @bind_values); $arrayref = $db->FetchAll($sql, @bind_values); $rv = $db->Do($sql, @bind_values); $original_args = $db->get_args(); # arrayref $dbh = $db->dbh(); # Raw DBI database handle
Provides a wrapper around DBI.
Note: the reason we don't test the connection and attempt to reconnect is that this module is most likely used in a web environment with mod_perl and Apache::DBI, and Apache::DBI will attempt to reconnect if the database connection dies.
These are the public methods provided.
my $db = DBIx::Wrapper::VerySimple->new($dsn,$user,password);
$dsn is a DBI DSN, for example:
$dsn = q{DBI:mysql:database='Accounting'};
or a more complex example:
$database = 'Accounting'; $host = 'data.ourdomain.com'; # Default is usually 'localhost' $port = '4200'; # 3306 is the MySQl default $dsn = "DBI:mysql:database=$database;host=$hostname;port=$port";
$hashref = $db->fetch_hash( $sql, @bind_values );
Returns a HASH ref for one row. Throws an exception if execution fails.
$arrayref = $db->fetch_all( $sql, @bind_values );
Returns an ARRAY ref of HASH refs. @bind_values are optional. Throws an exception if execution fails.
$result_code = $db->Do( $sql, @bind_values );
Executes a non-select SQL statement Throws an exception if execution fails.
$db->dbh();
Returns the raw database handle from DBI.
$db->get_args();
Returns an ARRAY ref of the original args to new();
DBI, Apache::DBI
DBIx::Simple, DBIx::Wrapper - have more features, but are not as simple as this module.
Matisse Enzer <matisse@matisse.net>
Copyright (c)2001-2006 by Matisse Enzer
This package is free software and is provided "as is" without express or implied warranty. It may be used, redistributed and/or modified under the terms of the Perl Artistic License (see http://www.perl.com/perl/misc/Artistic.html)
To install DBIx::Wrapper::VerySimple, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::Wrapper::VerySimple
CPAN shell
perl -MCPAN -e shell install DBIx::Wrapper::VerySimple
For more information on module installation, please visit the detailed CPAN module installation guide.