mirror of
				https://git.code.sf.net/p/seeddms/code
				synced 2025-10-31 05:11:27 +00:00 
			
		
		
		
	add optional parameter $col and $query to terms()
This commit is contained in:
		
							parent
							
								
									91c5b113b2
								
							
						
					
					
						commit
						68f19b87c3
					
				|  | @ -334,16 +334,33 @@ class SeedDMS_SQLiteFTS_Indexer { | |||
| 	/** | ||||
| 	 * Return list of terms in index | ||||
| 	 * | ||||
| 	 * This function does nothing! | ||||
| 	 * @return array list of SeedDMS_SQLiteFTS_Term | ||||
| 	 */ | ||||
| 	public function terms() { /* {{{ */ | ||||
| 	public function terms($query='', $col='') { /* {{{ */ | ||||
| 		if(!$this->_conn) | ||||
| 			return false; | ||||
| 
 | ||||
| 		if($this->_ftstype == 'fts5') | ||||
| 			$sql = "SELECT term, col, doc as occurrences FROM docs_terms WHERE col!='*' ORDER BY col"; | ||||
| 		else | ||||
| 			$sql = "SELECT term, col, occurrences FROM docs_terms WHERE col!='*' ORDER BY col"; | ||||
| 		if($this->_ftstype == 'fts5') { | ||||
| 			$sql = "SELECT term, col, doc as occurrences FROM docs_terms"; | ||||
| 			if($query || $col) { | ||||
| 				$sql .= " WHERE"; | ||||
| 				if($query) { | ||||
| 					$sql .= " term like '".$query."%'"; | ||||
| 					if($col) | ||||
| 						$sql .= " AND"; | ||||
| 				} | ||||
| 				if($col) | ||||
| 					$sql .= " col = '".$col."'"; | ||||
| 			} | ||||
| 			$sql .= " ORDER BY col, occurrences desc"; | ||||
| 		} else { | ||||
| 			$sql = "SELECT term, col, occurrences FROM docs_terms WHERE col!='*'"; | ||||
| 			if($query) | ||||
| 				$sql .= " AND term like '".$query."%'"; | ||||
| 			if($col) | ||||
| 				$sql .= " AND col = '".$col."'"; | ||||
| 			$sql .=	" ORDER BY col, occurrences desc"; | ||||
| 		} | ||||
| 		$res = $this->_conn->query($sql); | ||||
| 		$terms = array(); | ||||
| 		if($res) { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Uwe Steinmann
						Uwe Steinmann