File: SkillSearchQuery.class

package info (click to toggle)
gforge 4.5.14-22etch13
  • links: PTS
  • area: main
  • in suites: etch
  • size: 13,004 kB
  • ctags: 11,918
  • sloc: php: 36,047; sql: 29,050; sh: 10,538; perl: 6,496; xml: 3,810; makefile: 341; python: 263; ansic: 256
file content (55 lines) | stat: -rw-r--r-- 1,832 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php

/**
 * GForge Search Engine
 *
 * Portions Copyright 1999-2001 (c) VA Linux Systems
 * The rest Copyright 2004 (c) Guillaume Smet / Open Wide
 *
 * http://gforge.org
 *
 * @version $Id: SkillSearchQuery.class 5273 2006-02-08 18:47:59Z danper $
 */

require_once('common/search/SearchQuery.class');

class SkillSearchQuery extends SearchQuery {

	/**
	 * Constructor
	 *
	 * @param string $words words we are searching for
	 * @param int $offset offset
	 * @param boolean $isExact if we want to search for all the words or if only one matching the query is sufficient
	 */
	function SkillSearchQuery($words, $offset, $isExact) {	
		$this->SearchQuery($words, $offset, $isExact);	
	}

	/**
	 * getQuery - get the sql query built to get the search results
	 *
	 * @return string sql query to execute
	 */
	function getQuery() {
		global $sys_use_fti;
		if ($sys_use_fti) {		
			$words = $this->getFormattedWords();
			$sql = "SELECT skills_data.skills_data_id, skills_data.type, headline(skills_data.title, q) as title,
					skills_data.start,skills_data.finish,headline(skills_data.keywords, q) as keywords
					FROM skills_data, to_tsquery('$words') AS q, users, skills_data_types, skills_data_idx 
					WHERE skills_data.user_id=users.user_id AND skills_data.skills_data_id = skills_data_idx.skills_data_id 
					AND skills_data.type=skills_data_types.type_id AND (vectors @@ q) ORDER BY rank(vectors, q) DESC";
		} else {
			$sql = 'SELECT * '
				. 'FROM skills_data, users, skills_data_types '
				. 'WHERE (('.$this->getIlikeCondition('skills_data.title', $this->words).') '
				. 'OR ('.$this->getIlikeCondition('skills_data.keywords', $this->words).')) '
				. 'AND (skills_data.user_id=users.user_id) '
				. 'AND (skills_data.type=skills_data_types.type_id) '
				. 'ORDER BY finish DESC';
		}
		return $sql;
	}
}
?>