ILIAS  release_8 Revision v8.24
class.ilLikeUserDefinedFieldSearch.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
5
6
18{
19 public function setFields(array $a_fields): void
20 {
21 $fields = [];
22 foreach ($a_fields as $field) {
23 $fields[] = 'f_' . $field;
24 }
25 parent::setFields($fields);
26 }
27
28
29 public function __createWhereCondition(): string
30 {
31 $fields = $this->getFields();
32 $field = $fields[0];
33
34 $and = " WHERE field_id = " . $this->db->quote((int) substr($field, 2), "integer") . " AND ( ";
35 $counter = 0;
36 foreach ($this->query_parser->getQuotedWords() as $word) {
37 if ($counter++) {
38 $and .= " OR ";
39 }
40
41 if (strpos($word, '^') === 0) {
42 $and .= $this->db->like("value", "text", substr($word, 1) . "%");
43 } else {
44 $and .= $this->db->like("value", "text", "%" . $word . "%");
45 }
46 }
47 return $and . ") ";
48 }
49}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...