NAME
DBIx::Custom::Where - Where clause
SYNOPSYS
# Create DBIx::Custom::Where object
my $where = $dbi->where;
# Set clause and parameter
$where->clause(['and', ':title{like}', ':price{=}']);
# Create where clause by to_string method
my $where_clause = $where->to_string;
# Create where clause by stringify
my $where_clause = "$where";
# Created where clause in the above way
where :title{=} and :price{like}
# Only price condition
$where->clause(['and', ':title{like}', ':price{=}']);
$where->param({price => 1900});
my $where_clause = "$where";
# Created where clause in the above way
where :price{=}
# Only title condition
$where->clause(['and', ':title{like}', ':price{=}']);
$where->param({title => 'Perl'});
my $where_clause = "$where";
# Created where clause in the above way
where :title{like}
# Nothing
$where->clause(['and', ':title{like}', ':price{=}']);
$where->param({});
my $where_clause = "$where";
# or condition
$where->clause(['or', ':title{like}', ':price{=}']);
# More than one parameter
$where->clause(['and', ':price{>}', ':price{<}']);
$where->param({price => [1000, 2000]});
# Only first condition
$where->clause(['and', ':price{>}', ':price{<}']);
$where->param({price => [1000, $dbi->not_exists]});
# Only second condition
$where->clause(['and', ':price{>}', ':price{<}']);
$where->param({price => [$dbi->not_exists, 2000]});
# More complex condition
$where->clause(
[
'and',
':price{=}',
['or', ':title{=}', ':title{=}', ':title{=}']
]
);
my $where_clause = "$where";
# Created where clause in the above way
where :price{=} and (:title{=} or :title{=} or :title{=})
# Using Full-qualified column name
$where->clause(['and', ':book.title{like}', ':book.price{=}']);
ATTRIBUTES
clause
my $clause = $where->clause;
$where = $where->clause(
['and',
':title{=}',
['or', ':date{<}', ':date{>}']
]
);
Where clause. Above one is expanded to the following SQL by to_string If all parameter names is exists.
where title = :title and ( date < :date or date > :date )
param
my $param = $where->param;
$where = $where->param({
title => 'Perl',
date => ['2010-11-11', '2011-03-05'],
});
dbi
my $dbi = $where->dbi;
$where = $where->dbi($dbi);
DBIx::Custom object.
METHODS
DBIx::Custom::Where inherits all methods from Object::Simple and implements the following new ones.
to_string
$where->to_string;
Convert where clause to string.
double quote is override to execute to_string
method.
my $string_where = "$where";