MIDDAG for Moodle

operator : string

SQL operators supported by the MIDDAG Query Builder.

This enum defines all comparison and logical operators that can be used when building SQL WHERE clauses through the query builder. Each operator is mapped to its SQL representation and handles specific value types.

Table of Contents

Cases

BETWEEN  = 'BETWEEN'
Range operator (BETWEEN).
EQ  = '='
Equality operator (=).
GT  = '>'
Greater than operator (>).
GTE  = '>='
Greater than or equal operator (>=).
IN  = 'IN'
Set membership operator (IN).
IS  = 'IS'
NULL comparison operator (IS).
IS_NOT  = 'IS NOT'
Negated NULL comparison operator (IS NOT).
LIKE  = 'LIKE'
Pattern matching operator (LIKE).
LT  = '<'
Less than operator (<).
LTE  = '<='
Less than or equal operator (<=).
NEQ  = '<>'
Inequality operator (<>).
NOT_IN  = 'NOT IN'
Negated set membership operator (NOT IN).
RAW  = 'RAW'
Raw SQL operator (RAW).

Methods

between()  : self
Alias for BETWEEN.
equals()  : self
Alias for EQ (=).
greater_than()  : self
Alias for GT (>).
greater_than_or_equal()  : self
Alias for GTE (>=).
in()  : self
Alias for IN.
is()  : self
Alias for IS.
is_not()  : self
Alias for IS_NOT.
less_than()  : self
Alias for LT (<).
less_than_or_equal()  : self
Alias for LTE (<=).
like()  : self
Alias for LIKE.
not_equals()  : self
Alias for NEQ (<>).
not_in()  : self
Alias for NOT_IN.
raw()  : self
Alias for RAW.
sql()  : string
Return the SQL representation of this operator.

Cases

EQ

Equality operator (=).

Compares if a column value equals the provided value. Usage: WHERE column = value Accepts: scalar values (string, int, float, bool)

NEQ

Inequality operator (<>).

Compares if a column value is different from the provided value. Usage: WHERE column <> value Accepts: scalar values (string, int, float, bool)

GT

Greater than operator (>).

Compares if a column value is greater than the provided value. Usage: WHERE column > value Accepts: numeric or comparable values (int, float, string for dates)

GTE

Greater than or equal operator (>=).

Compares if a column value is greater than or equal to the provided value. Usage: WHERE column >= value Accepts: numeric or comparable values (int, float, string for dates)

LT

Less than operator (<).

Compares if a column value is less than the provided value. Usage: WHERE column < value Accepts: numeric or comparable values (int, float, string for dates)

LTE

Less than or equal operator (<=).

Compares if a column value is less than or equal to the provided value. Usage: WHERE column <= value Accepts: numeric or comparable values (int, float, string for dates)

LIKE

Pattern matching operator (LIKE).

Performs pattern matching using wildcards (% for multiple chars, _ for single char). Usage: WHERE column LIKE '%pattern%' Accepts: string values with optional wildcards Note: Wildcards must be included in the value itself

IN

Set membership operator (IN).

Checks if a column value matches any value in a provided list. Usage: WHERE column IN (value1, value2, value3) Accepts: array of scalar values

NOT_IN

Negated set membership operator (NOT IN).

Checks if a column value does not match any value in a provided list. Usage: WHERE column NOT IN (value1, value2, value3) Accepts: array of scalar values

BETWEEN

Range operator (BETWEEN).

Checks if a column value falls within a specified range (inclusive). Usage: WHERE column BETWEEN min AND max Accepts: array with exactly two elements [min, max]

IS

NULL comparison operator (IS).

Checks if a column value is NULL or a specific boolean value. Usage: WHERE column IS NULL or WHERE column IS TRUE Accepts: NULL, TRUE, FALSE Note: Use this instead of EQ for NULL comparisons

IS_NOT

Negated NULL comparison operator (IS NOT).

Checks if a column value is not NULL or not a specific boolean value. Usage: WHERE column IS NOT NULL or WHERE column IS NOT FALSE Accepts: NULL, TRUE, FALSE Note: Use this instead of NEQ for NULL comparisons

RAW

Raw SQL operator (RAW).

Allows insertion of arbitrary custom SQL operations without escaping. This bypasses all query builder safety mechanisms.

WARNING: Use with extreme caution — high risk of SQL injection. Should ONLY be used internally when the input is fully trusted and validated. Never use with user-provided input.

Usage: Internal use only for complex SQL expressions Accepts: trusted SQL string fragments

Methods

between()

Alias for BETWEEN.

public static between() : self

Checks if a value is within a range.

Return values
self

equals()

Alias for EQ (=).

public static equals() : self

Checks if a value equals another.

Return values
self

greater_than()

Alias for GT (>).

public static greater_than() : self

Checks if a value is greater than another.

Return values
self

greater_than_or_equal()

Alias for GTE (>=).

public static greater_than_or_equal() : self

Checks if a value is greater than or equal to another.

Return values
self

in()

Alias for IN.

public static in() : self

Checks if a value is in a list.

Return values
self

is()

Alias for IS.

public static is() : self

Checks if a value is NULL or a boolean.

Return values
self

is_not()

Alias for IS_NOT.

public static is_not() : self

Checks if a value is not NULL or not a boolean.

Return values
self

less_than()

Alias for LT (<).

public static less_than() : self

Checks if a value is less than another.

Return values
self

less_than_or_equal()

Alias for LTE (<=).

public static less_than_or_equal() : self

Checks if a value is less than or equal to another.

Return values
self

like()

Alias for LIKE.

public static like() : self

Pattern matching with wildcards.

Return values
self

not_equals()

Alias for NEQ (<>).

public static not_equals() : self

Checks if a value is not equal to another.

Return values
self

not_in()

Alias for NOT_IN.

public static not_in() : self

Checks if a value is not in a list.

Return values
self

raw()

Alias for RAW.

public static raw() : self

WARNING: Use with extreme caution - SQL injection risk!

Return values
self

sql()

Return the SQL representation of this operator.

public sql() : string
Return values
string

The SQL operator string


        
On this page

Search results