DBIx::Custom::QueryBuilder - Query builder
my $builder = DBIx::Custom::QueryBuilder->new; my $query = $builder->build_query( "select from table {= k1} && {<> k2} || {like k3}" );
tags
my $tags = $builder->tags; $builder = $builder->tags(\%tags);
Tags.
DBIx::Custom::QueryBuilder inherits all methods from Object::Simple and implements the following new ones.
build_query
my $query = $builder->build_query($source);
Create a new DBIx::Custom::Query object from SQL source. SQL source contains tags, such as {= title}, {like author}.
{ and } is reserved. If you use these charactors, you must escape them using '\'. Note that '\' is already perl escaped charactor, so you must write '\\'.
{
}
'select * from books \\{ something statement \\}'
Example:
SQL source
"select * from table where {= title} && {like author} || {<= price}"
Query
{ sql => "select * from table where title = ? && author like ? price <= ?;" columns => ['title', 'author', 'price'] }
register_tag
$builder->register_tag(\%tags); $builder->register_tag(%tags);
Register tag.
$builder->register_tag( '?' => sub { my $column = shift; return ['?', [$column]]; } );
See also DBIx::Custom::Tag to know tag.
To install DBIx::Custom, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::Custom
CPAN shell
perl -MCPAN -e shell install DBIx::Custom
For more information on module installation, please visit the detailed CPAN module installation guide.