DBIx::Printf::Named - A named-printf-style prepared statement
use DBIx::Printf::Named; use DBIx::Printf; my $sql = $dbh->nprintf( 'select * from t where str=%(str)s or int=%(int)d or float=%(float)f', { str => 'string', int => 1, float => 1.1e1 } );
DBIx::Printf::Named is a named-printf-style prepared statement. It adds a nprintf method to DBI::db package. This module is based on DBIx::Printf by kazuho oku.
DBIx::Printf::Named
nprintf
DBIx::Printf
Builds a SQL statement from given statement with placeholders and values. Following placeholders are supported.
%(key)d - integer %(key)f - floating point %(key)s - string %(key)t - do not quote, pass thru %like(fmt) - formats and quotes a string for like expression
Below is an example of using the %%like placeholder. Since metacharacters of supplied parameters are escaped, the example would always by a prefix search.
$dbh->printf('select * from t where name like %like(%(name)s%%)', { name => $name });
Masahiro Nagano <kazeburo {at} gmail.com>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install DBIx::Printf::Named, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::Printf::Named
CPAN shell
perl -MCPAN -e shell install DBIx::Printf::Named
For more information on module installation, please visit the detailed CPAN module installation guide.