ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilLikeUserMultiFieldSearch.php
Go to the documentation of this file.
1 <?php
2 
19 declare(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_data_multi " .
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  }
46  return $this->search_result;
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 }
$res
Definition: ltiservices.php:66
ilSearchResult $search_result