The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

DBIx::SQL::Abstract - 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;

DESCRIPTION

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.

EXPORT

None by default.

SEE ALSO

You may want to check out the DBI and the SQL::Abstract documentation. If you're interested in getting a better knowledge of its methods, please check it out.

See SQL::Abstract and DBI.

    perldoc SQL::Abstract
    perldoc DBI

AUTHOR

Alejandro Juarez, <alex@bsdcoders.org>

COPYRIGHT AND LICENSE

Copyright (C) 2004 by Alejandro Juarez

Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.