DBIx::SQL::Abstract 0.07 review
Download
|
|
DBIx::SQL::Abstract is a Perl module that provides a convenient abstraction layer to a database.
SYNOPSIS
use DBIx::SQL::Abstract;
my $dbh = DBIx::SQL::Abstract->new( %dbcfg );
Building SQL Abstractions.
my($query, @bind) = $dbh->select($table, @fields, %where, @order);
my($query, @bind) = $dbh->insert($table, %fieldvals || @values);
my($query, @bind) = $dbh->update($table, %fieldvals, %where);
my($query, @bind) = $dbh->delete($table, %where);
Using DBI methods
my $sth = $dbh->prepare($query);
$sth->execute(@bind_params);
...
my $rc = $dbh->begin_work;
my $rc = $dbh->commit;
my $rc = $dbh->rollback;
my $rc = $dbh->disconnect;
Anything else DBI method can be used, by Example:
my $err = $dbh->err;
my $err = $dbh->errstr;
my $rv = $dbh->state;
my $rc = $dbh->DESTROY;
The intention of this module is to join some methods from the DBI and the SQL::Abstract modules, for a convenient and easy use.
To begin, we create an object, but first we must create a hash which contains the database parameters as follows.
my %dbcfg = { PrintError => 1,
RaiseError => 0,
AutoCommit => 0,
ChopBlanks => 1
driver => 'Pg',
dbname => 'db',
host => undef,
port => undef,
user => 'user',
passwd => undef
};
Notice that this parameters are set as default unless you set your required values.
my $dbh = DBIx::SQL::Abstract->new( %dbcfg );
This object automatically creates the connection with the database, and gets the methods listed above.
Requirements:
Perl
DBIx::SQL::Abstract 0.07 search tags