Version: current

     1 <?php
     2 /**
     3  * @package sapphire
     4  * @subpackage search
     5  */
     6
     7 /**
     8  * Matches textual content with a substring match on a text fragment leading
     9  * to the end of the string.
    10  *
    11  * <code>
    12  *  "abcdefg" => "defg" # true
    13  *  "abcdefg" => "abcd" # false
    14  * </code>
    15  *
    16  * @package sapphire
    17  * @subpackage search
    18  */
    19 class EndsWithFilter extends SearchFilter {
    20
    21     /**
    22      * Applies a match on the trailing characters of a field value.
    23      *
    24      * @return unknown
    25      */
    26     public function apply(SQLQuery $query) {
    27         $query = $this->applyRelation($query);
    28         $query->where($this->getDbName() . " LIKE '%" . Convert::raw2sql($this->getValue()) . "'");
    29     }
    30
    31     public function isEmpty() {
    32         return $this->getValue() == null || $this->getValue() == '';
    33     }
    34 }
    35 ?>

[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. -