Search::QS::Filter - Incapsulation of a single filter element
version 0.03
use Search::QS::Filter; my $flt = new Search::QS::Filter; # parse query_string $flt->parse_qs($qs); # reconvert object to query_string print $flt->to_qs;
This object incapsulate a single filter element. Think of it about a single search element in an SQL string. Like
fullname = "Joe"
it has a fied "name()" "fullname", an "operator()" "=" and a "value()" "Joe".
The field name to search
The operator to use between field and value
An ARRAYREF with values to search in field name. It should be expanded with OR concatenation. As an example,
fld[x]=1&fld[x]=2
after parsing produce
name => 'x', values => [1,2]
and in SQL syntax must be written like
x=1 or x=2
In field name it can be use ":" to separe field name by a tag. The idea is to distinguish different operation with same field name.
As an example
fld[a:1]=1&fld[a:1]=$op:>&fld[a:2]=5&fld[a:2]=$op:<
must be
a>1 and a<5
If you set a field with $and:$groupvalue you set that this field in a AND group with other fields with same $groupvalue
As an example to
flt[d:1]=9&flt[d:1]=$and:1&flt[c:1]=2&flt[c:1]=$and:1&flt[d:2]=3&flt[d:2]=$and:2&flt[c:2]=1&flt[c:2]=$and:2
is traslated in
( d=9 AND c=2 ) OR ( d=3 and c=1 )
Like "andGroup()" but for OR operator
$perl_struct is an HASHREF which represents a query string like the one returned by "url_params_mixed" in URI::Encode. It parses the struct and extract filter informations
Return a query string of the internal rappresentation of the object
Return this object as a SQL search
Emiliano Bruni <info@ebruni.it>
This software is copyright (c) 2019 by Emiliano Bruni.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Search::QS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Search::QS
CPAN shell
perl -MCPAN -e shell install Search::QS
For more information on module installation, please visit the detailed CPAN module installation guide.