Appendix H. Perl DBI API ReferenceThis 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." |