2008-08-09 08:40:50 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @package sapphire
|
|
|
|
* @subpackage search
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Matches textual content with a substring match from the beginning
|
|
|
|
* of the string.
|
|
|
|
*
|
|
|
|
* <code>
|
|
|
|
* "abcdefg" => "defg" # false
|
|
|
|
* "abcdefg" => "abcd" # true
|
|
|
|
* </code>
|
|
|
|
*
|
|
|
|
* @package sapphire
|
|
|
|
* @subpackage search
|
|
|
|
*/
|
|
|
|
class StartsWithFilter extends SearchFilter {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Applies a substring match on a field value.
|
|
|
|
*
|
|
|
|
* @return unknown
|
|
|
|
*/
|
|
|
|
public function apply(SQLQuery $query) {
|
|
|
|
$query = $this->applyRelation($query);
|
2008-10-05 21:20:35 +02:00
|
|
|
$query->where(sprintf(
|
|
|
|
"LOCATE('%s', %s) = 1",
|
|
|
|
Convert::raw2sql($this->getValue()),
|
|
|
|
$this->getDbName()
|
|
|
|
));
|
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
|
|
|
}
|
|
|
|
?>
|