The WHERE clause, if given, indicates the condition or conditions that the records must satisfy to be selected.
Doctrine_Query provides easy to use WHERE -part management methods where and addWhere. The where methods always overrides
the query WHERE -part whereas addWhere adds new condition to the WHERE -part stack.
from('Group')->where('Group.id > 10');
// the same query using Doctrine_Expression component
\$e = \$q->expr;
\$coll = \$q->from('Group')->where(\$e->gt('Group.id', 10));
?>");
?>
Using regular expression operator:
query(\"FROM User WHERE User.name REGEXP '[ad]'\");
?>");
?>
DQL has support for portable LIKE operator:
select('u.*, e.*')
->from('User u LEFT JOIN u.Email e LEFT JOIN u.Phonenumber p')
->where(\"p.phonenumber LIKE '123%'\");
?>");
?>
Using multiple conditions and condition nesting are also possible:
select('u.*')
->from('User u LEFT JOIN u.Email e')
->where(\"u.name LIKE '%Jack%' AND e.address LIKE '%@drinkmore.info'\");
// nesting conditions
\$coll = \$q->select('u.*')
->from('User u LEFT JOIN u.Email e')
->where(\"u.name LIKE '%Jack%' OR u.name LIKE '%John%') AND e.address LIKE '%@drinkmore.info'\");
?>");
?>