EQL deep dive
Entity Query Language — PFM's query language for filtering records. EQL is parsed into an AST, compiled into parameterised SQL, and can also be evaluated in-memory for Business Rules.
EQL syntax
field=value^ORfield2!=value2^field3>=100^NQfield4ISEMPTY
| Symbol | Meaning |
|---|---|
^ | AND — both conditions must match |
^OR | OR within a group |
^NQ | New Query — opens a top-level OR group |
^! | NOT — negates the next condition |
Maximum 20 conditions per query.
Operators reference
| Operator | Aliases | Type | Example |
|---|---|---|---|
= | : | Comparison | status:open |
!= | Comparison | priority!=low | |
> | GT | Comparison | amount>100 |
>= | GTE | Comparison | total>=50 |
< | LT | Comparison | days<30 |
<= | LTE | Comparison | score<=80 |
STARTSWITH | ~^ | Text | nameSTARTSWITHJohn |
ENDSWITH | ~$ | Text | [email protected] |
CONTAINS | ~= | Text | descriptionCONTAINSurgent |
ISEMPTY | Null | resolutionISEMPTY | |
ISNOTEMPTY | Null | assigned_toISNOTEMPTY | |
IN | List | statusINopen,pending | |
NOTIN | List | typeNOTINspam,trash | |
BETWEEN | Range | amountBETWEEN100,500 | |
RELATIVE_GT | Date | created_atRELATIVE_GT-7d | |
RELATIVE_LT | Date | due_dateRELATIVE_LT+1M | |
SAMEAS | Field | shipping_citySAMEASbilling_city |
Business Rules operators
Only available inside Business Rule EQL filters:
| Operator | Description |
|---|---|
CHANGES | True if a field's value changed (pre-save vs post-save) |
DIDNOTCHANGE | True if a field's value did NOT change |
Special value tokens
| Token | Resolves to |
|---|---|
CURRENT_USER / CURRENT.USER / current_user() | Current WordPress user ID |
TRUE / FALSE | 1 / 0 |
EMPTY | Empty string |
Where EQL is evaluated
EQL is parsed once and then run in two modes:
- Against the database — for list views and REST queries, EQL compiles to a parameterised SQL
WHEREclause. SQL injection is impossible by construction; values are always parameter-bound. - In memory against a record — for Business Rules that need to look at
CHANGES/DIDNOTCHANGEbetween pre-save and post-save values, EQL is evaluated against the in-flight record without touching the database.