| DBIx-Placeholder-Named documentation | view source | Contained in the DBIx-Placeholder-Named distribution. |
DBIx::Placeholder::Named - DBI with named placeholders
use DBIx::Placeholder::Named;
my $dbh = DBIx::Placeholder::Named->connect($dsn, $user, $password)
or die DBIx::Placeholder::Named->errstr;
my $sth = $dbh->prepare(
q{ INSERT INTO some_table (this, that) VALUES (:this, :that) }
)
or die $dbh->errstr;
$sth->execute({ this => $this, that => $that, });
$dbh =
DBIx::Placeholder::Named->connect( $dsn, $user, $password,
{ PlaceholderPrefix => '__', PlaceholderSuffix => '**' } );
my $sth = $dbh->prepare(
q{ INSERT INTO some_table (this, that) VALUES (__this**, __that**) }
);
DBIx::Placeholder::Named is a subclass of DBI, which implements the ability to understand named placeholders.
This method, overloaded from DBI, is responsible to create a
new connection to database. It is overloaded to accept new keywords
within the $attr hash.
my $dbh =
DBIx::Placeholder::Named->connect( $dsn, $user, $password,
{ RaiseError => 1, PlaceholderSuffix => '', PlaceholderPrefix => ':', } );
By default, PlaceholderPrefix is : and PlaceholderSuffix is
empty string.
This method, overloaded from DBI, is responsible to create a
cached connection to database. It is overloaded to accept new keywords
within the $attr hash.
my $dbh =
DBIx::Placeholder::Named->connect_cached( $dsn, $user, $password,
{ RaiseError => 1, PlaceholderSuffix => '', PlaceholderPrefix => ':', } );
By default, PlaceholderPrefix is : and PlaceholderSuffix is
empty string.
This method, overloaded from DBI (DBI::db), is responsible to create a prepared statement for further execution. It is overloaded to accept a SQL query which has named placeholders, like:
SELECT a, b, c FROM t WHERE id = :id
It uses SQL::Tokenizer to correctly tokenize the SQL query, preventing extract erroneous placeholders (date/time specifications, comments, inside quotes or double quotes, etc).
Gabor Szabo <szabgab@gmail.com> for requesting prefix support.
Copyright (c) 2007, Igor Sutton Lopes "<IZUT@cpan.org>". All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| DBIx-Placeholder-Named documentation | view source | Contained in the DBIx-Placeholder-Named distribution. |