mirror of
https://github.com/processwire/processwire.git
synced 2025-08-15 11:14:12 +02:00
Add support for matching empty/not-empty to DatabaseQuerySelectFulltext match features
This commit is contained in:
@@ -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
|
||||
*
|
||||
|
Reference in New Issue
Block a user