ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLikeUserDefinedFieldSearch.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
31{
32 public function setFields(array $a_fields): void
33 {
34 $fields = [];
35 foreach ($a_fields as $field) {
36 $fields[] = 'f_' . $field;
37 }
38 parent::setFields($fields);
39 }
40
41
42 public function __createWhereCondition(): string
43 {
44 $fields = $this->getFields();
45 $field = $fields[0];
46
47 $and = " WHERE field_id = " . $this->db->quote((int) substr($field, 2), "integer") . " AND ( ";
48 $counter = 0;
49 foreach ($this->query_parser->getQuotedWords() as $word) {
50 if ($counter++) {
51 $and .= " OR ";
52 }
53
54 if (strpos($word, '^') === 0) {
55 $and .= $this->db->like("value", "text", substr($word, 1) . "%");
56 } else {
57 $and .= $this->db->like("value", "text", "%" . $word . "%");
58 }
59 }
60 return $and . ") ";
61 }
62}
$counter