Name : perl-DBD-mysql
| |
Version : 3.0002
| Vendor : Patrick Galbraith < patg_mysql_com>
|
Release : 1
| Date : 2005-07-22 10:22:42
|
Group : Applications/CPAN
| Source RPM : perl-DBD-mysql-3.0002-1.src.rpm
|
Size : 0.39 MB
| |
Packager : Peter Pramberger < peter_pramberger_member_fsf_org>
| |
Summary : DBD-mysql - A MySQL driver for the Perl5 Database Interface (DBI)
|
Description :
B< DBD::mysql> is the Perl5 Database Interface driver for the MySQL database. In other words: DBD::mysql is an interface between the Perl programming language and the MySQL programming API that comes with the MySQL relational database management system. Most functions provided by this programming API are supported. Some rarely used functions are missing, mainly because noone ever requested them. :-)
In what follows we first discuss the use of DBD::mysql, because this is what you will need the most. For installation, see the sections on L< INSTALLATION>, and L< WIN32 INSTALLATION> below. See L< EXAMPLE> for a simple example above.
From perl you activate the interface with the statement
use DBI;
After that you can connect to multiple MySQL database servers and send multiple queries to any of them via a simple object oriented interface. Two types of objects are available: database handles and statement handles. Perl returns a database handle to the connect method like so:
$dbh = DBI->connect(\"DBI:mysql:database=$db;host=$host\", $user, $password, {RaiseError => 1});
Once you have connected to a database, you can can execute SQL statements with:
my $query = sprintf(\"INSERT INTO foo VALUES (%d, %s)\", $number, $dbh->quote(\"name\")); $dbh->do($query);
See L< DBI(3)> for details on the quote and do methods. An alternative approach is
$dbh->do(\"INSERT INTO foo VALUES (?, ?)\", undef, $number, $name);
in which case the quote method is executed automatically. See also the bind_param method in L< DBI(3)>. See L< DATABASE HANDLES> below for more details on database handles.
If you want to retrieve results, you need to create a so-called statement handle with:
$sth = $dbh->prepare(\"SELECT * FROM $table\"); $sth->execute();
This statement handle can be used for multiple things. First of all you can retreive a row of data:
my $row = $sth->fetchow_hashref();
If your table has columns ID and NAME, then $row will be hash ref with keys ID and NAME. See L< STATEMENT HANDLES> below for more details on statement handles.
But now for a more formal approach:
|
RPM found in directory: /packages/linux-pbone/archive/ftp.pramberger.at/systems/linux/contrib/rh73/i386 |