silverstripe-framework/search/filters/SubstringFilter.php

28 lines
493 B
PHP

<?php
/**
* @package sapphire
* @subpackage search
*/
/**
* Uses a substring match against content in column rows.
*
* @package sapphire
* @subpackage search
*/
class SubstringFilter extends SearchFilter {
public function apply(DataQuery $query) {
return $query->filter(sprintf(
"LOCATE('%s', %s) != 0",
Convert::raw2sql($this->getValue()),
$this->getDbName()
));
}
public function isEmpty() {
return $this->getValue() == null || $this->getValue() == '';
}
}
?>