home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-perl-addon-1.4.9-installer.exe / NullP.pm < prev    next >
Encoding:
Text File  |  2004-02-25  |  2.9 KB  |  129 lines

  1. {
  2.     package DBD::NullP;
  3.  
  4.     require DBI;
  5.  
  6.     @EXPORT = qw(); # Do NOT @EXPORT anything.
  7.     $VERSION = sprintf("%d.%02d", q$Revision: 11.4 $ =~ /(\d+)\.(\d+)/o);
  8.  
  9. #   $Id: NullP.pm,v 11.4 2004/01/07 17:38:51 timbo Exp $
  10. #
  11. #   Copyright (c) 1994, Tim Bunce
  12. #
  13. #   You may distribute under the terms of either the GNU General Public
  14. #   License or the Artistic License, as specified in the Perl README file.
  15.  
  16.     $drh = undef;    # holds driver handle once initialised
  17.     $err = 0;        # The $DBI::err value
  18.  
  19.     sub driver{
  20.     return $drh if $drh;
  21.     my($class, $attr) = @_;
  22.     $class .= "::dr";
  23.     ($drh) = DBI::_new_drh($class, {
  24.         'Name' => 'NullP',
  25.         'Version' => $VERSION,
  26.         'Attribution' => 'DBD Example Null Perl stub by Tim Bunce',
  27.         }, [ qw'example implementors private data']);
  28.     $drh;
  29.     }
  30.  
  31.     sub CLONE {
  32.         undef $drh;
  33.     }
  34. }
  35.  
  36.  
  37. {   package DBD::NullP::dr; # ====== DRIVER ======
  38.     $imp_data_size = 0;
  39.     use strict;
  40.     # we use default (dummy) connect method
  41.  
  42.     sub DESTROY { undef }
  43. }
  44.  
  45.  
  46. {   package DBD::NullP::db; # ====== DATABASE ======
  47.     $imp_data_size = 0;
  48.     use strict;
  49.  
  50.     sub prepare {
  51.     my($dbh, $statement)= @_;
  52.  
  53.     my($outer, $sth) = DBI::_new_sth($dbh, {
  54.         'Statement'     => $statement,
  55.         }, [ qw'example implementors private data']);
  56.  
  57.     $outer;
  58.     }
  59.  
  60.     sub FETCH {
  61.     my ($dbh, $attrib) = @_;
  62.     # In reality this would interrogate the database engine to
  63.     # either return dynamic values that cannot be precomputed
  64.     # or fetch and cache attribute values too expensive to prefetch.
  65.     return 1 if $attrib eq 'AutoCommit';
  66.     # else pass up to DBI to handle
  67.     return $dbh->DBD::_::db::FETCH($attrib);
  68.     }
  69.  
  70.     sub STORE {
  71.     my ($dbh, $attrib, $value) = @_;
  72.     # would normally validate and only store known attributes
  73.     # else pass up to DBI to handle
  74.     if ($attrib eq 'AutoCommit') {
  75.         return 1 if $value; # is already set
  76.         croak("Can't disable AutoCommit");
  77.     }
  78.     return $dbh->DBD::_::db::STORE($attrib, $value);
  79.     }
  80.  
  81.     sub DESTROY { undef }
  82. }
  83.  
  84.  
  85. {   package DBD::NullP::st; # ====== STATEMENT ======
  86.     $imp_data_size = 0;
  87.     use strict;
  88.  
  89.     sub execute {
  90.     my($sth, $data) = @_;
  91.     $sth->{dbd_nullp_data} = $data if $data;
  92.     $sth->{NAME} = [ "fieldname" ];
  93.     1;
  94.     }
  95.  
  96.     sub fetch {
  97.     my($sth) = @_;
  98.     my $data = $sth->{dbd_nullp_data};
  99.         if ($data) {
  100.         $sth->{dbd_nullp_data} = undef;
  101.         return [ $data ];
  102.     }
  103.     $sth->finish;     # no more data so finish
  104.     return undef;
  105.     }
  106.  
  107.     sub finish {
  108.     my($sth) = @_;
  109.     }
  110.  
  111.     sub FETCH {
  112.     my ($sth, $attrib) = @_;
  113.     # would normally validate and only fetch known attributes
  114.     # else pass up to DBI to handle
  115.     return $sth->DBD::_::st::FETCH($attrib);
  116.     }
  117.  
  118.     sub STORE {
  119.     my ($sth, $attrib, $value) = @_;
  120.     # would normally validate and only store known attributes
  121.     # else pass up to DBI to handle
  122.     return $sth->DBD::_::st::STORE($attrib, $value);
  123.     }
  124.  
  125.     sub DESTROY { undef }
  126. }
  127.  
  128. 1;
  129.