NAME

Tao::DBI - Portable support for named placeholders in DBI statements

SYNOPSIS

use Tao::DBI qw(dbi_connect);

$dbh = dbi_connect({ dsn => $dsn, user => $user, pass => $pass });
$sql = q{UPDATE T set a = :a, b = :b where k = :k};
$stmt = $dbh->prepare($sql);
$rc = $stmt->execute({ k => $k, a => $a, b => $b });

DESCRIPTION

THIS IS PRE-ALPHA SOFTWARE! MANY BUGS LURKING AROUND!

perldoc DBI - section "Placeholders and Bind Values"

"Some drivers also allow placeholders like :name and :n (e.g., :1, :2, and so on) in addition to ?, but their use is not portable."

dbi_connect
my $dbh = dbi_connect($args);

Returns a new database connection built from the arguments in hash ref $args.

dbi_prepare
my $sth = dbi_prepare($args);

Returns a new prepared statement. This statement supports named placeholders (like :a) whether the driver supports it or not. (However, the driver has to support ? placeholders.)

You don't have to import this function if you plan to create DBI connections via Tao::DBI::dbi_connect, because these will automatically support SQL with named placeholders in prepare.

EXPORT

dbi_connect and dbi_prepare can be exported on demand.

SEE ALSO

DBI

BUGS

Please report bugs via CPAN RT http://rt.cpan.org/NoAuth/Bugs.html?Dist=Tao-DBI.

AUTHOR

Adriano R. Ferreira, <ferreira@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2005 by Adriano R. Ferreira

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.