ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilLikeUserMultiFieldSearch.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once './Services/Search/classes/class.ilAbstractSearch.php';
5 
18 {
19 
24  public function __construct($qp_obj)
25  {
26  parent::__construct($qp_obj);
27  }
28 
33  public function &performSearch()
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  {
46  $this->search_result->addEntry($row->usr_id,'usr',$this->__prepareFound($row));
47  }
48  return $this->search_result;
49  }
50 
51 
57  public function setFields($a_fields)
58  {
59  foreach($a_fields as $field)
60  {
61  $fields[] = $field;
62  }
63  parent::setFields($fields ? $fields : array());
64  }
65 
66 
68  {
69  global $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  {
78  if($counter++)
79  {
80  $and .= " OR ";
81  }
82 
83  if(strpos($word,'^') === 0)
84  {
85  $and .= $ilDB->like("value", "text", substr($word,1)."%");
86  }
87  else
88  {
89  $and .= $ilDB->like("value", "text", "%".$word."%");
90  }
91  }
92  return $and.") ";
93  }
94 }
95 ?>
getFields()
Get fields to search.
__createLocateString()
build locate string in case of AND search
$counter
__construct($qp_obj)
Constructor public.
Create styles array
The data for the language used.
global $ilDB