mirror of
https://github.com/processwire/processwire.git
synced 2025-08-23 06:44:38 +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 {
|
} else {
|
||||||
$value = $this->value($value);
|
$value = $this->value($value);
|
||||||
$method = $this->method;
|
$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);
|
$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
|
* Match LIKE phrase
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user