home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

Book HomeProgramming the Perl DBISearch this book

Appendix A. DBI Specification

This appendix is a slightly edited version of the DBI specification, a "living document" that evolves at a slow but steady pace as new versions of the DBI are released. This document is based on the DBI specification for DBI version 1.14.

Although we know that it will be slightly out of date by the time you read it, we have included this specification in the book because it is important reference material, and we believe the book would be incomplete without it. For up-to-date information, consult the online documentation for the version of the DBI you have installed. You can usually access the online documentation with the perldoc DBI command. The Changes file supplied with the DBI distribution contains detailed change information.

Note that whenever the DBI changes, the drivers take some time to catch up. Recent versions of the DBI have added new features (marked NEW in the text) that may not yet be supported by the drivers you use. Talk to the authors of those drivers if you need support for new features.

A.1. Synopsis

use DBI;

@driver_names = DBI->available_drivers;
@data_sources = DBI->data_sources($driver_name);

$dbh = DBI->connect($data_source, $username, $auth, \%attr);

$rv  = $dbh->do($statement);
$rv  = $dbh->do($statement, \%attr);
$rv  = $dbh->do($statement, \%attr, @bind_values);

$ary_ref = $dbh->selectall_arrayref($statement);
@row_ary = $dbh->selectrow_array($statement);
$ary_ref = $dbh->selectcol_arrayref($statement);

$sth = $dbh->prepare($statement);
$sth = $dbh->prepare_cached($statement);

$rv = $sth->bind_param($p_num, $bind_value);
$rv = $sth->bind_param($p_num, $bind_value, $bind_type);
$rv = $sth->bind_param($p_num, $bind_value, \%attr);

$rv = $sth->execute;
$rv = $sth->execute(@bind_values);

$rc = $sth->bind_col($col_num, \$col_variable);
$rc = $sth->bind_columns(@list_of_refs_to_vars_to_bind);

@row_ary  = $sth->fetchrow_array;
$ary_ref  = $sth->fetchrow_arrayref;
$hash_ref = $sth->fetchrow_hashref;

$ary_ref  = $sth->fetchall_arrayref;

$rv  = $sth->rows;

$rc  = $dbh->commit;
$rc  = $dbh->rollback;

$sql = $dbh->quote($string);

$rc  = $h->err;
$str = $h->errstr;
$rv  = $h->state;

$rc  = $dbh->disconnect;

A.1.1. Getting Help

If you have questions about DBI, you can get help from the mailing list. You can subscribe to the list by visiting:

http://www.isc.org/dbi-lists.html

Also worth a visit is the DBI home page at:

http://www.symbolstone.org/technology/perl/DBI

Before asking any questions, reread this document, consult the archives, and read the DBI FAQ. The archives are listed at the end of this document. The FAQ is installed as a DBI::FAQ module, so you can read it by executing perldoc DBI::FAQ.

Please note that Tim Bunce does not maintain the mailing lists or the web page (generous volunteers do that). So please don't send mail directly to him; he just doesn't have the time to answer questions personally. The dbi-users mailing list has lots of experienced people who should be able to help you if you need it.



Library Navigation Links

Copyright © 2001 O'Reilly & Associates. All rights reserved.











??????????????@Mail.ru