UMMF::Export::Perl::DBI - Old DBI forwards-compatibility.


UMMF documentation Contained in the UMMF distribution.

Index


Code Index:

NAME

Top

UMMF::Export::Perl::DBI - Old DBI forwards-compatibility.

SYNOPSIS

Top

DESCRIPTION

Top

This package provides tools for old versions of DBI.

USAGE

Top

use DBI; use UMMF::Export::Perl::DBI;

EXPORT

Top

None exported.

TO DO

Top

AUTHOR

Top

Kurt Stephens, kstephens@users.sourceforge.net 2004/03/29

SEE ALSO

Top

DBI,

VERSION

Top

$Revision: 1.2 $

METHODS

Top


UMMF documentation Contained in the UMMF distribution.

package UMMF::Export::Perl::DBI;

use 5.6.0;
use strict;
use warnings;

our $AUTHOR = q{ kstephens@users.sourceforge.net 2004/03/29 };
our $VERSION = do { my @r = (q$Revision: 1.2 $ =~ /\d+/g); sprintf "%d." . "%03d" x $#r, @r };

#######################################################################

# use base qw(NOTHING);

#######################################################################

use DBI;

#######################################################################
# Backward compatiability with DBI 1.14.
#

if ( ! UNIVERSAL::can('DBI::db', 'selectall_hashref') 
#     || $DBI::VERSION eq '1.42'
 ) 
{
  eval q{
        package DBI::db;

        #print STDERR "Adding selectall_hashref\n";

        sub selectall_hashref
        {
            my ($dbh, $stmt, $key) = @_;

            my %hash;

            # $DB::single = 1;

            my $sth = ref($stmt) ? $stmt : $dbh->prepare($stmt);
            $sth->execute();

            while ( my $row = $sth->fetchrow_hashref() ) {
                die("Fetched row is not a hash") unless ref($row) eq 'HASH';
                $hash{$row->{$key}} = $row;
            }

            $sth->finish;

            wantarray ? %hash : \%hash;
        }

    };
  die($@) if $@;
}


if ( ! UNIVERSAL::can('DBI::db', 'selectrow_hashref') 
#     || $DBI::VERSION eq '1.42'
 ) 
{
  eval q{
        package DBI::db;
        
        #print STDERR "Adding selectrow_hashref\n";

        sub selectrow_hashref
        {
            my ($dbh, $stmt) = @_;

            my %hash;

            # $DB::single = 1;

            my $sth = ref($stmt) ? $stmt : $dbh->prepare($stmt);
            $sth->execute();

            my $row = $sth->fetchrow_hashref();

            $sth->finish;

            $row;
        }

    };
  die($@) if $@;
}


#######################################################################

1;

#######################################################################


### Keep these comments at end of file: kstephens@users.sourceforge.net 2003/04/06 ###
### Local Variables: ###
### mode:perl ###
### perl-indent-level:2 ###
### perl-continued-statement-offset:0 ###
### perl-brace-offset:0 ###
### perl-label-offset:0 ###
### End: ###