diff --git a/wire/core/DatabaseQuerySelectFulltext.php b/wire/core/DatabaseQuerySelectFulltext.php index 0dda284d..2a056828 100644 --- a/wire/core/DatabaseQuerySelectFulltext.php +++ b/wire/core/DatabaseQuerySelectFulltext.php @@ -311,7 +311,16 @@ class DatabaseQuerySelectFulltext extends Wire { } else { $value = $this->value($value); $method = $this->method; - if(strlen($value)) $this->$method($value); + if(strlen($value)) { + $this->$method($value); + } else { + // empty value + if($this->not || $this->operator === '!=') { + $this->matchIsNotEmpty(); + } else { + $this->matchIsEmpty(); + } + } } } @@ -388,6 +397,22 @@ class DatabaseQuerySelectFulltext extends Wire { $this->query->where("$this->tableField$op?", $value); } + /** + * Match is an empty empty string, null or not present + * + */ + protected function matchIsEmpty() { + $this->query->where("($this->tableField='' OR $this->tableField IS NULL)"); + } + + /** + * Match is present, not null and not an empty string + * + */ + protected function matchIsNotEmpty() { + $this->query->where("($this->tableField IS NOT NULL AND $this->tableField!='')"); + } + /** * Match LIKE phrase *