6 * Portions Copyright 1999-2001 (c) VA Linux Systems
7 * The rest Copyright 2004 (c) Guillaume Smet / Open Wide
14 require_once('common/search/SearchQuery.class.php');
16 class SkillSearchQuery extends SearchQuery {
21 * @param string $words words we are searching for
22 * @param int $offset offset
23 * @param boolean $isExact if we want to search for all the words or if only one matching the query is sufficient
25 function SkillSearchQuery($words, $offset, $isExact) {
26 $this->SearchQuery($words, $offset, $isExact);
30 * getQuery - get the sql query built to get the search results
32 * @return string sql query to execute
37 if(count($this->words)) {
38 $words = $this->getFormattedWords();
39 $tsquery0 = "headline(skills_data.title, q) as title, headline(skills_data.keywords, q) as keywords ";
40 $tsquery = ", to_tsquery('$words') AS q, skills_data_idx";
41 $tsmatch = "vectors @@ q";
43 $tsjoin = 'AND skills_data.skills_data_id = skills_data_idx.skills_data_id ';
44 $orderBy = "ORDER BY rank(vectors, q) DESC, finish DESC";
45 $phraseOp = $this->getOperator();
47 $tsquery0 = "title, keywords ";
52 $orderBy = "ORDER BY finish DESC";
56 if(count($this->phrases)) {
57 $phraseCond .= $phraseOp.'('
58 . ' ('.$this->getMatchCond('skills_data.title', $this->phrases).')'
59 . ' OR ('.$this->getMatchCond('skills_data.keywords', $this->phrases).'))';
61 $sql = 'SELECT skills_data.skills_data_id, skills_data.type, '
62 . 'skills_data.start, skills_data.finish, '.$tsquery0
63 . 'FROM skills_data, users, skills_data_types '
65 . ' WHERE (vectors @@ q '.$phraseCond.') '
67 . 'AND (skills_data.user_id=users.user_id) '
68 . 'AND (skills_data.type=skills_data_types.type_id) '
72 . 'FROM skills_data, users, skills_data_types '
73 . 'WHERE (('.$this->getIlikeCondition('skills_data.title', $this->words).') '
74 . 'OR ('.$this->getIlikeCondition('skills_data.keywords', $this->words).')) '
75 . 'AND (skills_data.user_id=users.user_id) '
76 . 'AND (skills_data.type=skills_data_types.type_id) '
77 . 'ORDER BY finish DESC';