1 <?php
2 /**
3 * @package sapphire
4 * @subpackage search
5 */
6
7 /**
8 * Matches textual content with a substring match from the beginning
9 * of the string.
10 *
11 * <code>
12 * "abcdefg" => "defg" # false
13 * "abcdefg" => "abcd" # true
14 * </code>
15 *
16 * @package sapphire
17 * @subpackage search
18 */
19 class StartsWithFilter extends SearchFilter {
20
21 /**
22 * Applies a substring match on 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 ?>