NAME

DBIx::bind_param_inline - list variables in $dbh->prepare method instead of calling $sth->bind_param

SYNOPSIS

Syntactic sugar allowing implied statement parameters, like in SQR.

use DBI;
...
use DBIx::bind_param_inline;
our ($foo, $bar, $baz); # MUST be "our" not "my"
# qq style -- escape rods of Asclepius
my $sth = prepare_inline($dbh, <<SQL);
SELECT * from mytable WHERE foo = \$foo AND bar = \$bar AND baz = \$baz
SQL
# q style -- noninterpolative
my $sth2 = prepare_inline($dbh, <<'SQL');
INSERT INTO mytable (foo, bar, baz) VALUES ($foo, $bar, ? )
SQL
...
$sth->execute(); #placeholders get bound for you
$sth2->execute($something->compute_baz); # regular placeholders still work!
...

DESCRIPTION

prepare_inline identifies inlined variables and replaces them with ? placeholders before calling the normal prepare. The resulting statement handle has some additional information in it so bind_param will be called when it is executed, and all other methods called on it fall through to the non-extended statement handle.

EXPORT

prepare_inline

HISTORY

0.01

SEE ALSO

http://perlbuzz.com/2008/12/database-access-in-perl-6-is-coming-along-nicely.html

AUTHOR

David Nicol <davidnico@cpan.org<gt>

COPYRIGHT AND LICENSE

Copyright (C) 2008 by David Nicol

This library is released into the public domain.