Ilia Lobsanov


DBIx::AbstractLite - Lightweight DBI SQL abstraction in a hybrid interface


  use Project::DB;

  my $DB = new Project::DB; # connect to DB
  $DB->setWhere('date >= sysdate-1'); # global condition for all queries to follow
  my $sth = $DB->select({
      fields    => [ 'user', 'email' ],
      table     => 'users',
      where     => { 'user'             => [ 'like', 'me%' ],
                     'length(email)'    => [ '>', '20' ],
      }) or die $DB->error();
  print $sth->fetchrow_array();

  $DB->query('SELECT user, email FROM users WHERE user like ?', 'me%') 
    or die $DB->error();
  my $userEmail = $DB->fetch_hash();
  print "someuser's email is: ", $userEmail->{someuser}, "\n";

  $DB->query('SELECT email FROM users WHERE user = ?', 'me') 
    or die $DB->error();
  print "my email is ", $DB->fetch_col();

  package Project::DB;

  use DBIx::AbstractLite;
  use vars qw (@ISA);
  @ISA = qw(DBIx::AbstractLite);

  sub _initMembers {
    my ($self) = @_;

    $self->{DSN} = "dbi:Oracle:$ENV{ORACLE_SID}";
    $self->{USER} = 'username';
    $self->{PASS} = 'password';


This module is based on DBIx::Abstract, but is much simpler. It also doesn't deviate from the DBI interface as much as DBIx::Abstract does. The main similarity between DBIx::AbstractLite and DBIx::Abstract is in the select method. Unlike Abstract, AbstractLite is not 100% abstract in that it still allows conventional access to the DBI interface, using plain SQL and the DBI statement handle methods.

CGI::LogCarp is used internally to trace the queries sent to DBI. To see the trace statements, add this statement at the beginning of your program: use CGI::LogCarp qw(:STDBUG);



Ilia Lobsanov <>


  Copyright (c) 2001 Ilia Lobsanov, Nurey Networks Inc.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.