Writing PHP Scripts


Appendix H. Perl DBI API Reference

This appendix describes the Perl DBI application programming interface. The API consists of a set of methods and attributes for communicating with database servers and accessing databases from Perl scripts. The appendix also describes MySQL-specific extensions to DBI provided by DBD::mysql, the MySQL database driver. It does not describe the older Mysqlperl interface, which is obsolete.

I assume here a minimum version of DBI 1.32, which requires at least Perl 5.6.0 (and 5.6.1 is preferred to 5.6.0). You must have at least DBD::mysql 2.0900 for transaction support, which is the minimum version assumed here. Changes in behavior from that version on are noted. However, if you are using MySQL 4.1.3 or later, changes were made to the MySQL C API that require a minimum DBD::mysql version of 2.9004.

MySQL 4.1.3 or later also is required to use the DBD::mysql mysql_server_prepare option that accesses the support for server-side prepared statements that is present in the C client library. However, the mysql_server_prepare option itself currently is available only in the DBD::mysql development repository. It should be present in DBD::mysql 3.0, which should be available soon if not by the time you read this.

To determine your versions of DBI and DBD::mysql, run this program:

 #! /usr/bin/perl -w # dbi-version.pl - display DBI and DBD::mysql versions use strict; use DBI; print "DBI::VERSION: $DBI::VERSION\n"; use DBD::mysql; print "DBD::mysql::VERSION: " . $DBD::mysql::VERSION . "\n"; 

Some DBI methods and attributes are not discussed here, either because they do not apply to MySQL or because they are new, experimental methods that may change as they are developed or may even be dropped. Some MySQL-specific DBD methods are not discussed because they are obsolete. If you want more information about new or obsolete methods, see the DBI documentation or the MySQL DBD documentation, which you can get by running the following commands:

 % perldoc DBI % perldoc DBI::FAQ % perldoc DBD::mysql 

This appendix serves as a reference, so it includes only brief code fragments illustrating use of the Perl DBI API. For complete client scripts and instructions for writing them, see Chapter 7, "Writing MySQL Programs Using Perl DBI."



MySQL The definitive guide to using, programming, and administering MySQL 4. 1 and 5. 0
Mysql: the Definitive Guide to Using, Programming, and Administering Mysql 4.1 and 5.0
ISBN: B003A1PKHY
EAN: N/A
Year: 2004
Pages: 190
Authors: Paul Dubois

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net