Function: WHERE
The WHERE function in Wonderful Relations queries is equivalent to the classic SQL WHERE clause. It allows you to define filter conditions that restrict the result set of a query.
Multiple conditions can be added. These conditions are automatically combined using **AND**. If you require OR logic, you must manually include it in the condition string (e.g., status = 'open' OR status = 'pending').
This is a core function to make queries dynamic, customizable, and filterable at runtime—especially when combined with placeholder value replacement.
Usage Notes
- Each condition is limited to 250 characters (due to the database column limit).
- Conditions support dynamic value replacement using the
##placeholder##syntax. - All conditions defined in the WHERE section are evaluated together during query execution.
Example Condition
status = 'active'Or dynamically:
status = ##status##In your template or execution, you would then pass:
$executor = new Executor();
$result = $executor->get_results('query', array( 'filter_status' => 'active' ));Resulting in:
status = 'active'Summary
✅ Allows classic SQL-style filtering of query results
✅ Supports dynamic value replacement for reusability
✅ Fully integrated into the Wonderful Relations query engine
The WHERE function is one of the most frequently used components and provides essential control over the data returned by a query.
