Version: current

     1 <?php
     2 /**
     3  * @package sapphire
     4  * @subpackage search
     5  */
     6
     7 /**
     8  * Uses a substring match against content in column rows.
     9  *
    10  * @package sapphire
    11  * @subpackage search
    12  */
    13 class SubstringFilter extends SearchFilter {
    14
    15     public function apply(SQLQuery $query) {
    16         return $query->where(sprintf(
    17             "LOCATE('%s', %s) != 0",
    18             Convert::raw2sql($this->getValue()),
    19             $this->getDbName()
    20         ));
    21     }
    22
    23     public function isEmpty() {
    24         return $this->getValue() == null || $this->getValue() == '';
    25     }
    26 }
    27
    28 ?>

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -