DBI::Simple - Perl extension to allow easy DBI access
use DBI::Simple; $dbi = DBI::Simple->connect('mysql:hostname=localhost;database=main', 'user', 'pass'); $rs = $dbi->query('SELECT * FROM Users'); while(!$rs->eof) { print "Client = " . $rs->client . "\n"; print "ID = " . $rs->id . "\n";
print "\n\n\n a list of all fields and their values:\n";
print "$_ = $rs->{data}->{$_}\n" for keys(%{$rs->{data}});
$rs->move_next;
}
$dbi->disconnect;
DBI::Simple abstracts the internals of the DBI module. It encapsulates the DBI, so you retain all the functionality of the DBI when using DBI::Simple.
Any DBI function can be accessed by returning the DBI::Simple object's underlying database handle. This handle
can be retrieved with the dbh function. The following functions are members of the DBI::Simple package:
connect
The connect function takes the same parameters as the corresponding DBI function. However, it is not necessary to
specify "dbi:" in the string. That is, the strings "dbi:mysql:...." and "mysql:..." are equivalent.
dbh
The dbh method returns the underlying DBI database handle.
query($statement)
The query function returns the the DBI::Simple::Recordset manpage object that results from executing $statement.
Requires the DBI module and any necessary DBD drivers.
None by default. All functions are object-oriented.
Update database when members of hash are changed
Cache prepared statements for better performance
Enable transaction-based updating
Create tests.
Insert and Delete methods
the DBI::Simple::Recordset manpage, the DBI manpage, DBD::*
Bill Atkins, <cpanNOSPAM@batkins.com>
Copyright 2003 by Bill Atkins
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.