ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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
4include_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 $GLOBALS['ilLog']->write(__METHOD__.': '.$query);
44
45 $res = $this->db->query($query);
46 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
47 {
48 $this->search_result->addEntry($row->usr_id,'usr',$this->__prepareFound($row));
49 }
51 }
52
53
59 public function setFields($a_fields)
60 {
61 foreach($a_fields as $field)
62 {
63 $fields[] = $field;
64 }
65 parent::setFields($fields ? $fields : array());
66 }
67
68
70 {
71 global $ilDB;
72
73 $fields = $this->getFields();
74 $field = $fields[0];
75
76 $and = " WHERE field_id = ".$ilDB->quote($field, "text")." AND ( ";
77 $counter = 0;
78 foreach($this->query_parser->getQuotedWords() as $word)
79 {
80 if($counter++)
81 {
82 $and .= " OR ";
83 }
84
85 if(strpos($word,'^') === 0)
86 {
87 $and .= $ilDB->like("value", "text", substr($word,1)."%");
88 }
89 else
90 {
91 $and .= $ilDB->like("value", "text", "%".$word."%");
92 }
93 }
94 return $and.") ";
95 }
96}
97?>
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
__createLocateString()
build locate string in case of AND search
getFields()
Get fields to search.
__construct($qp_obj)
Constructor @access public.
$GLOBALS['ct_recipient']
global $ilDB