Michael Shipper > DBIx-SimpleGoBetween-1.003 > DBIx::SimpleGoBetween

Download:
DBIx-SimpleGoBetween-1.003.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 1.003   Source  

NAME ^

DBIx::SimpleGoBetween - DBI Wrapper interface

SYNOPSIS ^

  use DBIx::SimpleGoBetween;
  use DBI;

  my $dbh=DBI->connect(blah blah blah);

  my $db=DBIx::SimpleGoBetween->new(\$dbh);


  # returns the first column of the first row of your query
  $count=$db->get_scalar('select count(*) from table_a');

  # fetches the entire result set as a single list
  ($max,$sum)=$db->get_list(
    'select max(column_a) ,sum(column_a) from table_a'
  );

  # returns a list reference of list references
  # each list reference represents a row from the result set
  $array_ref=$db->get_list_of_lists(
    'select * from table_a'
  );

  # returns a list reference of hash references
  # each hash reference represents a row from the result set
  $array_ref=$db->get_list_of_hashes(
    'select * from table_a'
  );

  # does a prepare then executes the query with the list reference 
  # provide by the 2nd argument
  $db->sql_do('delete from table_a where column_a=?',[$value]);

  # Callback
  # code_ref: is called on a per row basis, arguments based on 'type'
  # type: array,hash,array_ref,hash_ref
  $sth=$db->callback(
    'sql',[execute list],[prepare_args],'type',\&code_ref
  );

DESCRIPTION ^

DBIx::SimpleGoBetween acts as a go between for DBI and any other development interfaces you use. This package has no iterators, no error checking. It simply returns the result sets in one of many data structure formants.

Odds are your result does not need to be processed, just placed in a structure in the order it was retrieved, if so then this is the module you are looking for.

Example using HTML::Template

  use DBI;
  use DBIx::SimpleGoBetween;
  use HTML::Template;

  my $dbh=DBH->connect();
  my $db=DBIx::SimpleGoBetween->new(\$dbh);
  my $tmpl=HTML::Template->new(filename=>'file.tmpl');

  $tmpl->param(
    total_rows=>$db->get_scalar('select count(*) from table_a')
    ,tmpl_loop=>$db->get_list_of_hashes('select * from table_a')
  );

EXPORT

None

OO Methods

This section documents the OO functions

OO interface arguments

All OO interfaces in the instance accept the following arguments:

  -'sql statement'
   Required argument
    Must be an "sql statment" or a "prepared statement handle"

  -[execute list]
   Optional argument ( manditory if [optional prepare args] is used )
     Must be an array reference containing the place holder arguments
     for the $sth->execute command

  -[optional prepare args]
   Optional argument ( manditory if you are using $db->callback )
     Must be an array reference of the arguments passed to
     $dbh->prepare('sql statement',@{[optional prepare args]})

SEE ALSO ^

DBI HTML::Template DBIx::BulkLoader::Mysql DBIx::Simple

Source Forge Porject ^

If you feel this software is useful please donate.

DBIx Simple Go Between

AUTHOR ^

Michael Shipper

COPYRIGHT AND LICENSE ^

Copyright (C) 2010 by Michael Shipper

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available.

syntax highlighting: