ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilLikeUserMultiFieldSearch Class Reference
+ Inheritance diagram for ilLikeUserMultiFieldSearch:
+ Collaboration diagram for ilLikeUserMultiFieldSearch:

Public Member Functions

 __construct ($qp_obj)
 Constructor public. More...
 
 performSearch ()
 Perform search. More...
 
 setFields ($a_fields)
 
 __createWhereCondition ()
 
- Public Member Functions inherited from ilAbstractSearch
 __construct ($qp_obj)
 Constructor public. More...
 
 setFields ($a_fields)
 Set fields to search. More...
 
 getFields ()
 Get fields to search. More...
 
 setFilter ($a_filter)
 set object type to search in More...
 
 setIdFilter ($a_id_filter)
 Set id filter Filters search by given object id. More...
 
 getIdFilter ()
 Get Id filter. More...
 
 appendToFilter ($a_type)
 Append object type to filter. More...
 
 getFilter ()
 get object type to search in More...
 
 __createLocateString ()
 build locate string in case of AND search More...
 
 __prepareFound (&$row)
 
 performSearch ()
 

Additional Inherited Members

- Data Fields inherited from ilAbstractSearch
 $db = null
 
 $query_parser = null
 
 $search_result = null
 
 $object_types
 

Detailed Description

Definition at line 17 of file class.ilLikeUserMultiFieldSearch.php.

Constructor & Destructor Documentation

◆ __construct()

ilLikeUserMultiFieldSearch::__construct (   $qp_obj)

Constructor public.

Definition at line 24 of file class.ilLikeUserMultiFieldSearch.php.

25  {
26  parent::__construct($qp_obj);
27  }

Member Function Documentation

◆ __createWhereCondition()

ilLikeUserMultiFieldSearch::__createWhereCondition ( )

Definition at line 65 of file class.ilLikeUserMultiFieldSearch.php.

References $DIC, $ilDB, and ilAbstractSearch\getFields().

Referenced by performSearch().

66  {
67  global $DIC;
68 
69  $ilDB = $DIC['ilDB'];
70 
71  $fields = $this->getFields();
72  $field = $fields[0];
73 
74  $and = " WHERE field_id = " . $ilDB->quote($field, "text") . " AND ( ";
75  $counter = 0;
76  foreach ($this->query_parser->getQuotedWords() as $word) {
77  if ($counter++) {
78  $and .= " OR ";
79  }
80 
81  if (strpos($word, '^') === 0) {
82  $and .= $ilDB->like("value", "text", substr($word, 1) . "%");
83  } else {
84  $and .= $ilDB->like("value", "text", "%" . $word . "%");
85  }
86  }
87  return $and . ") ";
88  }
getFields()
Get fields to search.
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ performSearch()

ilLikeUserMultiFieldSearch::performSearch ( )

Perform search.

Returns
type

Definition at line 33 of file class.ilLikeUserMultiFieldSearch.php.

References $query, $res, $row, ilAbstractSearch\$search_result, ilAbstractSearch\__createLocateString(), __createWhereCondition(), and ilDBConstants\FETCHMODE_OBJECT.

34  {
35  $where = $this->__createWhereCondition();
36  $locate = $this->__createLocateString();
37 
38  $query = "SELECT usr_id " .
39  $locate .
40  "FROM usr_data_multi " .
41  $where;
42 
43  $res = $this->db->query($query);
44  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
45  $this->search_result->addEntry($row->usr_id, 'usr', $this->__prepareFound($row));
46  }
47  return $this->search_result;
48  }
__createLocateString()
build locate string in case of AND search
foreach($_POST as $key=> $value) $res
$query
$row
+ Here is the call graph for this function:

◆ setFields()

ilLikeUserMultiFieldSearch::setFields (   $a_fields)
Parameters

Definition at line 56 of file class.ilLikeUserMultiFieldSearch.php.

57  {
58  foreach ($a_fields as $field) {
59  $fields[] = $field;
60  }
61  parent::setFields($fields ? $fields : array());
62  }

The documentation for this class was generated from the following file: