QCubed Query Conditions
All QCubed Query method calls require a Condition. Conditions allow you to create a nested/hierarchical set of conditions to describe what essentially becomes your WHERE clause in a SQL query statement.
The following is the list of Condition classes and what parameters they take:
- QQ::all()
- QQ::none()
- QQ::equal(NodeBase, Value)
- QQ::notEqual(NodeBase, Value)
- QQ::greaterThan(NodeBase, Value)
- QQ::lessThan(NodeBase, Value)
- QQ::greaterOrEqual(NodeBase, Value)
- QQ::lessOrEqual(NodeBase, Value)
- QQ::isNull(NodeBase)
- QQ::isNotNull(NodeBase)
- QQ::in(NodeBase, array of string/int/datetime)
- QQ::like(NodeBase, string)
For almost all of the above Conditions, you are comparing a column with some value. The Node parameter represents that column. However, the value can be either a static value (like an integer, a string, a datetime, etc.) or it can be another Node.
And finally, there are three special Condition classes which take in any number of additional Condition classes:
- QQ::andCondition()
- QQ::orCondition()
- QQ::not() - "Not" can only take in one Condition class
(conditions can be passed in as parameters and/or as arrays)
Because And/Or/Not conditions can take in any other condition, including other And/Or/Not conditions, you can embed these conditions into other conditions to create what ends up being a logic tree for your entire SQL Where clause. See below for more information on this.
Select all People where: the first name is alphabetically "greater than" the last name
- John Doeooo
- Mike Ho
- Wendy Smith
- Samantha Jones
- Linda Brady
- Joseph Biden
- Joseph Biden
- Joseph Biden
- sdbv asdgvb
- sdbv asdgvb
- John Doe
- Johnww Doe
Select all Projects where: the manager's first name is alphabetically "greater than" the last name, or who's name contains "Website"
- ACME Website Redesign (managed by Karen Wolfe)
- State College HR Systzzzz (managed by Mike Ho)
- Blueman Industrial Site Architecture (managed by John Doeooo)
Select all Projects where: the Project ID <= 2 AND (the manager's first name is alphabetically "greater than" the last name, or who's name contains "Website")
- ACME Website Redesign (managed by Karen Wolfe)
- State College HR Systzzzz (managed by Mike Ho)