ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLikeUserMultiFieldSearch.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
31{
32 public function performSearch(): ilSearchResult
33 {
34 $where = $this->__createWhereCondition();
35 $locate = $this->__createLocateString();
36
37 $query = "SELECT usr_id " .
38 $locate .
39 "FROM usr_profile_data " .
40 $where;
41
42 $res = $this->db->query($query);
43 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
44 $this->search_result->addEntry($row->usr_id, 'usr', $this->__prepareFound($row));
45 }
47 }
48
49
50 public function setFields(array $a_fields): void
51 {
52 $fields = [];
53 foreach ($a_fields as $field) {
54 $fields[] = $field;
55 }
56 parent::setFields($fields);
57 }
58
59
60 public function __createWhereCondition(): string
61 {
62 $fields = $this->getFields();
63 $field = $fields[0];
64
65 $and = " WHERE field_id = " . $this->db->quote($field, "text") . " AND ( ";
66 $counter = 0;
67 foreach ($this->query_parser->getQuotedWords() as $word) {
68 if ($counter++) {
69 $and .= " OR ";
70 }
71
72 if (strpos($word, '^') === 0) {
73 $and .= $this->db->like("value", "text", substr($word, 1) . "%");
74 } else {
75 $and .= $this->db->like("value", "text", "%" . $word . "%");
76 }
77 }
78 return $and . ") ";
79 }
80}
ilSearchResult $search_result
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$res
Definition: ltiservices.php:69
$counter