DB::DBinterface - Perl extension for really simply access to database
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
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.
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.
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 ;-)");
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')
=item * new_h :
constructor when used in other class (heritate form)
accessor for setting DBHOST
accessor for getting value of DBHOST
accessor for setting DBUSER
accessor for getting value of DBUSER
accessor for setting DBPASSWORD
accessor for getting value of DBPASSWORD
accessor for setting DBDATABASE
accessor for getting value of DBDATABASE
a method wich print debug informations
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()
execute the SQL request REQUEST (all but ``SELECT-like'' request)
execute a ``describe'' SQL request on TABLE and return a hash with to key : Field and Type (values are separated by a coma)
execute a ``describe'' SQL request on TABLE and return a table wich contain ref on hash with 2 keys : Field and Type.
DUPUIS Arnaud, <a.dupuis@infinityperl.org>
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.