Ilia Lobsanov > DBIx-AbstractLite-0.02 > DBIx::AbstractLite

Download:
DBIx-AbstractLite-0.02.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 1.05   Source  

NAME ^

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

SYNOPSIS ^

  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';
  }

DESCRIPTION ^

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);

MORE DOCUMENTATION TBD...

AUTHOR ^

Ilia Lobsanov <ilia@lobsanov.com>

COPYRIGHT ^

  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.

syntax highlighting: