Skip to content

ComparisonOperator Enum

The ComparisonOperator enum defines various SQL comparison operators used in database queries. It provides a type-safe way to work with SQL conditions in the Sparkle package.

Available Values

ConstantSQL OperatorDescription
EQUAL'='Checks if two values are equal.
GREATER_THAN'>'Checks if the left value is greater than the right value.
GREATER_THAN_OR_EQUAL'>='Checks if the left value is greater than or equal to the right value.
NOT_EQUAL'!='Checks if two values are not equal.
NOT_EQUAL_ALT'<>'Alternative syntax for checking inequality.
LESS_THAN'<'Checks if the left value is less than the right value.
LESS_THAN_OR_EQUAL'<='Checks if the left value is less than or equal to the right value.
BETWEEN'BETWEEN'Checks if a value is within a given range.
LIKE'LIKE'Performs a pattern match using wildcards (% or _).
IN'IN'Checks if a value exists within a set of values.
ALL'ALL'Compares a value against all values in a subquery.
AND'AND'Logical AND operator to combine conditions.
ANY'ANY'Checks if a value matches any value returned by a subquery.
EXISTS'EXISTS'Checks if a subquery returns any results.
NOT'NOT'Negates a condition.
OR'OR'Logical OR operator to combine conditions.
SOME'SOME'Equivalent to ANY, checks if any value matches.

Example Usage

You can use the ComparisonOperator enum when building database queries:

php
use Sirmerdas\Sparkle\Enums\ComparisonOperator;

$operator = ComparisonOperator::GREATER_THAN;

if ($operator === ComparisonOperator::GREATER_THAN) {
    echo "The condition is checking for values greater than a given value.";
}

This enum helps make query conditions more readable and maintainable in your application.

Released under the MIT License.