From fdccf268e319420bc4425b81d4e930e2331c4cbc Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Fri, 22 Aug 2014 15:38:18 -0500 Subject: [PATCH] orm: Implement __isnull match criteria --- include/class.orm.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/class.orm.php b/include/class.orm.php index 264582fb6..d638a7dc9 100644 --- a/include/class.orm.php +++ b/include/class.orm.php @@ -808,7 +808,7 @@ class MySqlCompiler extends SqlCompiler { 'lt' => '%1$s < %2$s', 'gte' => '%1$s >= %2$s', 'lte' => '%1$s <= %2$s', - 'isnull' => '%1$s IS NULL', + 'isnull' => array('self', '__isnull'), 'like' => '%1$s LIKE %2$s', 'hasbit' => '%1$s & %2$s != 0', 'in' => array('self', '__in'), @@ -830,6 +830,12 @@ class MySqlCompiler extends SqlCompiler { return sprintf('%s IN (%s)', $a, $b); } + function __isnull($a, $b) { + return $b + ? sprintf('%s IS NULL', $a) + : sprintf('%s IS NOT NULL', $a); + } + function compileJoin($tip, $model, $alias, $info) { $constraints = array(); $join = ' JOIN '; -- GitLab