NAME
SQL::Entity::Condition - Entity SQL Condition abstraction.
DESCRIPTION
Represents sql condition.
SYNOPSIS
use SQL::Entity::Condition ':all';
#Creates "a = 1" condition
my $cond = sql_cond('a', '=', 1);
#Creates "a = 1 AND b > 1 AND c < 1" condition
my $cond = sql_and(
sql_cond('a', '=', 1),
sql_cond('b', '>', 1),
sql_cond('c', '<', 1),
);
Creates "a = 1 OR b > 1 OR c < 1" condition
my $cond = sql_or(
sql_cond('a', '=', 1),
sql_cond('b', '>', 1),
sql_cond('c', '<', 1),
);
Creates "(a = 1 AND b = 1) OR c LIKE 1" condition
my $cond = sql_and(
sql_cond('a', '=', 1),
sql_cond('b', '=', 1),
)->or(
sql_cond('c', 'LIKE', 1)
);
EXPORT
None by default. sql_cond sql_and sql_or by tag 'all'
ATTRIBUTES
- operand1
-
First operand for condition.
- operator
-
Operator
- operand2
-
Second operand for condition.
- relation
-
Relation between compsite condition.
- conditions
-
Association to composie condition
METHOD
- new
- condition_iterator
- sql_cond( string | SQL::Entity::Column: $operand1, string: $operator, string | SQL::Entity::Column: $operand2) returns SQL::Entity::Condition
-
Create simple Condition object.
- and(ARRAY $condition_list) returns SQL::Entity::Condition
-
Create a composite Condition object with AND relation between current object and passed in condition list.
- ord(ARRAY $condition_list) returns SQL::Entity::Condition
-
Create a composite Condition object with OR relation between current object an passed in condition list.
- sql_andd(ARRAY $condition_list) returns SQL::Entity::Condition
-
Create a composite Condition object with AND relation.
- sql_ord(ARRAY $condition_list) returns SQL::Entity::Condition
-
Create a composite Condition object with OR relation.
- sql_composite(ARRAY $condition_list) returns SQL::Entity::Condition
-
Create a composite Condition object.
- as_string
-
Converts condition to string
- operand
-
Return expression for passed in operand.
- struct_to_condition
-
Converts passed in data structure to condition object. SQL::Entity::Condition->struct_to_condition(a => 1, b => 3); converts to a = 1 AND b = 3
SQL::Entity::Condition->struct_to_condition(a => 1, b => [1,3]); converts to a = 1 AND b IN (1,3)
SQL::Entity::Condition->struct_to_condition(a => 1, b => {operator => '!=', operand => 3}); converts to a = 1 AND b != 3
SQL::Entity::Condition->struct_to_condition(a => 1, b => {operator => 'LIKE', operand => "'A%'", relation => 'OR'}); coverts to a = 1 OR b LIKE 'A%'
- convert_extended_operand
-
Return operator, operand2, relation for passed in operand
SEE ALSO
SQL::Query SQL::Entity SQL::Entity::Column
COPYRIGHT AND LICENSE
The SQL::Entity::Condition module is free software. You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file.
AUTHOR
Adrian Witas, adrian@webapp.strefa.pl