++ed by:
AZJADFTRE STAUGAARD FUKAI XIAOCANG

4 PAUSE users
7 non-PAUSE users.

Yuki Kimoto

NAME

DBIx::Custom::QueryBuilder - Query builder

SYNOPSIS

    my $builder = DBIx::Custom::QueryBuilder->new;
    my $query = $builder->build_query(
        "select from table {= k1} && {<> k2} || {like k3}"
    );

ATTRIBUTES

tags

    my $tags = $builder->tags;
    $builder = $builder->tags(\%tags);

Tags.

METHODS

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.

Example:

    $builder->register_tag(
        '?' => sub {
            my $column = shift;
            
            return ['?', [$column]];
        }
    );

See also DBIx::Custom::Tag to know tag.