The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

DB::DBinterface - Perl extension for really simply access to database

SYNOPSIS

  use DB::DBinterface;
  use strict;
  my $dbo = DB::DBinterface(
        DBUSER => 'user' ,
        DBPASSWORD => 'p4ssw0rd',
        DBHOST => '192.168.0.20',
        DATABASE => 'my_database',
        DBTYPE => 'mysql'
  );
  my @results = $dbo->DBselect("SELECT * FROM users");
  $dbo->DBupdate("CREATE TABLE my_table (id_table tinyint, name_table varchar(200)");
  $dbo->DBupdate("INSERT INTO my_table VALUES(1,'toto')");
  my @results = $dbo->DBselect("SELECT * FROM my_table");
  print "====> Results for my_table <====\n\nID\tTABLE NAME\n---------------\n";
  foreach my $a (@results)
  {
        print "$a->{id_table}\t$a->{name_table}";
  }
  my @tab = $dbo->getRefTabShemaFromTable('my_table');
  print "Field for 'my_table' : $tab[0]->{Field}\n";
  my %schema = $dbo->getShemaHashFromTable('my_table');
  print "Type for 'my_table' : $schema{Type}\n";
  print 

DESCRIPTION

DB::DBinterface provide an interface to DBI and DBD::* modules. It used DBI, so you might install it and the corresponding DBD driver if necessary.

FUNCTIONS

  • DBencode(CHARSET,(TEXT|$TEXT|@TEXT)) :

    Encode text to escape characters wich can be dangerous in an ``SQL injection'' attack.

    Availables CHARSET are :

            ip-wm
            
            ip-wm-fr

    Return a table containing decoded text.

  • DBencode(CHARSET,(TEXT|$TEXT|@TEXT)) :

    Decode TEXT wich have been encoded with DNencode for CHARSET. Return a table containing decoded text.

    You can also use this two functions like methods ($dbo->DBecode('ip-wm',"toto is beautifull ;-)");

METHODS

  • new :

     constructor when used alone. Arguments are :
            DBHOST : IP adress or hostname of the database (default is 127.0.0.1)
            
            DBUSER : A username wich is authoryzed to connect to database (default is undef)
            
            DBPASSWORD : The password associates with DBUSER (default is undef)
            
            DATABASE : the database name (default is undef)
            
            DBTYPE : the DBI driver name (default is 'mysql')
    
            
  • new_h :

     constructor when used in other class (heritate form)
  • setDBHOST(VALUE) :

     accessor for setting DBHOST
  • getDBHOST :

     accessor for getting value of DBHOST
  • setDBUSER(VALUE) :

     accessor for setting DBUSER
  • getDBUSER :

     accessor for getting value of DBUSER
  • setDBPASSWORD(VALUE) :

     accessor for setting DBPASSWORD
  • getDBPASSWORD :

     accessor for getting value of DBPASSWORD
  • setDATABASE(VALUE) :

     accessor for setting DBDATABASE
  • getDATABASE :

     accessor for getting value of DBDATABASE
  • debugTrace :

     a method wich print debug informations
  • DBselect(REQUEST) :

     execute the SQL request REQUEST (only for ``SELECT-like'' request). Returned a table wich contain references on hash table create by a call to the DBI method : fetchrow_hashref()
  • DBupdate(REQUEST) :

     execute the SQL request REQUEST (all but ``SELECT-like'' request)
  • getShemaHashFromTable(TABLE) :

     execute a ``describe'' SQL request on TABLE and return a hash with to key : Field and Type (values are separated by a coma)
  • getRefTabShemaFromTable(TABLE) :

     execute a ``describe'' SQL request on TABLE and return a table wich contain ref on hash with 2 keys : Field and Type.

AUTHOR

DUPUIS Arnaud, <a.dupuis@infinityperl.org>

COPYRIGHT AND LICENSE

Copyright (C) 2004 by DUPUIS Arnaud

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.3 or, at your option, any later version of Perl 5 you may have available.

4 POD Errors

The following errors were encountered while parsing the POD:

Around line 502:

'=item' outside of any '=over'

Around line 520:

You forgot a '=back' before '=head1'

Around line 523:

'=item' outside of any '=over'

Around line 593:

You forgot a '=back' before '=head1'