NAME
DBIx::Placeholder::Named - DBI with named placeholders
SYNOPSIS
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**) }
);
DESCRIPTION
DBIx::Placeholder::Named is a subclass of DBI, which implements the ability to understand named placeholders.
METHODS
- DBIx::Placeholder::Named::connect()
-
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:
andPlaceholderSuffix
is empty string. - DBIx::Placeholder::Named::connect_cached()
-
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:
andPlaceholderSuffix
is empty string. - DBIx::Placeholder::Named::db::prepare()
-
This method, overloaded from DBI, 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).
- DBIx::Placeholder::Named::st::execute()
THANKS
Gabor Szabo <szabgab@gmail.com> for requesting prefix support.
AUTHOR
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.