2008-08-09 08:40:50 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2012-04-12 08:02:46 +02:00
|
|
|
* @package framework
|
2008-08-09 08:40:50 +02:00
|
|
|
* @subpackage search
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Matches textual content with a substring match on a text fragment leading
|
|
|
|
* to the end of the string.
|
|
|
|
*
|
|
|
|
* <code>
|
|
|
|
* "abcdefg" => "defg" # true
|
|
|
|
* "abcdefg" => "abcd" # false
|
|
|
|
* </code>
|
|
|
|
*
|
2012-04-12 08:02:46 +02:00
|
|
|
* @package framework
|
2008-08-09 08:40:50 +02:00
|
|
|
* @subpackage search
|
|
|
|
*/
|
|
|
|
class EndsWithFilter extends SearchFilter {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Applies a match on the trailing characters of a field value.
|
|
|
|
*
|
|
|
|
* @return unknown
|
|
|
|
*/
|
2011-03-21 09:37:55 +01:00
|
|
|
public function apply(DataQuery $query) {
|
|
|
|
$this->model = $query->applyRelation($this->relation);
|
2012-03-14 16:05:28 +01:00
|
|
|
return $query->where(sprintf(
|
|
|
|
"%s %s '%%%s'",
|
|
|
|
$this->getDbName(),
|
|
|
|
(DB::getConn() instanceof PostgreSQLDatabase) ? 'ILIKE' : 'LIKE',
|
|
|
|
Convert::raw2sql($this->getValue())
|
|
|
|
));
|
2008-08-09 08:40:50 +02:00
|
|
|
}
|
|
|
|
|
2008-08-11 02:03:57 +02:00
|
|
|
public function isEmpty() {
|
|
|
|
return $this->getValue() == null || $this->getValue() == '';
|
|
|
|
}
|
2008-08-09 08:40:50 +02:00
|
|
|
}
|