Repository navigation
getValidOperator
Corey Avis edited this page Sep 23, 2026
·
2 revisions
This method validates if the provided comparison operator is valid; if not, it defaults to the equality operator ('='). This method accepts standard MySQL operators as well as user-friendly shorthands, which are automatically normalized to their proper SQL equivalents.
getValidOperator(?string $operator, bool &$valid = false): string
operator (string) : The comparison operator to validate.
| Valid Operators | Description |
|---|---|
| = or == | Equals |
| <> or != | Not equal to |
| < | Less than |
| > | Greater than |
| <= | Less than or equal to |
| >= | Greater than or equal to |
| <=> | Null-safe not equal |
| % | Search |
| %= | Ends with search |
| =% | Starts with search |
valid (bool)
: If valid is populated, then it returns true or false if the provided comparison operator is valid. ^(optional)^
(string)
: Returns the normalized MySQL operator string (e.g., returns '=' if '==' was provided, or '<>' if '!=' was provided.) If the provided operator is invalid, then it defaults to '='.
$db->getValidOperator() = '='
$db->getValidOperator('>') = '>'
$db->getValidOperator('!') = '='
- No debug errors.