@@ -1248,6 +1248,29 @@ conditions:
12481248 # WHERE country_id NOT IN ('AFG', 'USA', 'EST')
12491249 ```
12501250
1251+ - ` inOrNull() ` Create a condition for ` IN ` combined with ` IS NULL ` :
1252+
1253+ ``` php
1254+ $query = $cities->find()
1255+ ->where(function (QueryExpression $exp, SelectQuery $q) {
1256+ return $exp->inOrNull('country_id', ['AFG', 'USA', 'EST']);
1257+ });
1258+ # WHERE (country_id IN ('AFG', 'USA', 'EST') OR country_id IS NULL)
1259+ ```
1260+
1261+ ::: info Added in version 5.4.0
1262+ :::
1263+
1264+ - ` notInOrNull() ` Create a condition for ` NOT IN ` combined with ` IS NULL ` :
1265+
1266+ ``` php
1267+ $query = $cities->find()
1268+ ->where(function (QueryExpression $exp, SelectQuery $q) {
1269+ return $exp->notInOrNull('country_id', ['AFG', 'USA', 'EST']);
1270+ });
1271+ # WHERE (country_id NOT IN ('AFG', 'USA', 'EST') OR country_id IS NULL)
1272+ ```
1273+
12511274- ` gt() ` Create a ` > ` condition:
12521275
12531276 ``` php
@@ -1318,6 +1341,19 @@ conditions:
13181341 # WHERE population BETWEEN 999 AND 5000000,
13191342 ```
13201343
1344+ - ` notBetween() ` Create a ` NOT BETWEEN ` condition:
1345+
1346+ ``` php
1347+ $query = $cities->find()
1348+ ->where(function (QueryExpression $exp, SelectQuery $q) {
1349+ return $exp->notBetween('population', 999, 5000000);
1350+ });
1351+ # WHERE population NOT BETWEEN 999 AND 5000000
1352+ ```
1353+
1354+ ::: info Added in version 5.4.0
1355+ :::
1356+
13211357- ` exists() ` Create a condition using ` EXISTS ` :
13221358
13231359 ``` php
@@ -1352,6 +1388,43 @@ conditions:
13521388 # WHERE NOT EXISTS (SELECT id FROM cities WHERE countries.id = cities.country_id AND population > 5000000)
13531389 ```
13541390
1391+ - ` isDistinctFrom() ` Create a null-safe inequality comparison using ` IS DISTINCT FROM ` :
1392+
1393+ ``` php
1394+ $query = $cities->find()
1395+ ->where(function (QueryExpression $exp, SelectQuery $q) {
1396+ return $exp->isDistinctFrom('status', 'active');
1397+ });
1398+ # WHERE status IS DISTINCT FROM 'active'
1399+ # MySQL uses: NOT (status <=> 'active')
1400+ ```
1401+
1402+ This is useful when you need to compare values where ` NULL ` should be treated
1403+ as a distinct value. Unlike regular ` != ` comparisons, ` IS DISTINCT FROM `
1404+ returns ` TRUE ` when comparing ` NULL ` to a non-NULL value, and ` FALSE ` when
1405+ comparing ` NULL ` to ` NULL ` .
1406+
1407+ ::: info Added in version 5.4.0
1408+ :::
1409+
1410+ - ` isNotDistinctFrom() ` Create a null-safe equality comparison using ` IS NOT DISTINCT FROM ` :
1411+
1412+ ``` php
1413+ $query = $cities->find()
1414+ ->where(function (QueryExpression $exp, SelectQuery $q) {
1415+ return $exp->isNotDistinctFrom('category_id', null);
1416+ });
1417+ # WHERE category_id IS NOT DISTINCT FROM NULL
1418+ # MySQL uses: category_id <=> NULL
1419+ ```
1420+
1421+ This is the null-safe equivalent of ` = ` . It returns ` TRUE ` when both values
1422+ are ` NULL ` (unlike regular ` = ` which returns ` NULL ` ), making it useful for
1423+ comparing nullable columns.
1424+
1425+ ::: info Added in version 5.4.0
1426+ :::
1427+
13551428Expression objects should cover many commonly used functions and expressions. If
13561429you find yourself unable to create the required conditions with expressions you
13571430can may be able to use ` bind() ` to manually bind parameters into conditions:
0 commit comments