Jeff PHP framework
0.99
Modular, extensible, OOP, MVC, lightweight php framework designed to ease the programmers in the development of web applications.
|
Full text search tool (mysql DBMS) More...
Public Member Functions | |
__construct ($table, $opts=null) | |
Constructs a search instance. | |
getSearchResults ($selected_fields, $required_clauses, $weight_clauses) | |
Return the search results. | |
makeQuery ($selected_fields, $required_clauses, $weight_clauses) | |
Creation of the search query. | |
Private Member Functions | |
clearSearchString ($search_string) | |
Clear the search string. | |
getKeywords ($search_string) | |
Gets keywords from a search string. | |
Private Attributes | |
$_registry | |
the registry singleton instance | |
$_table | |
the database table |
Full text search tool (mysql DBMS)
This class is used to perform full text seraches optionally indicating different weights for different search fields.
In order to work correctly the database engine must have defined the following function which is a case insensitive replace function. here is the SQL code necessary to create the replace_ci function:
DELIMITER $$ DROP FUNCTION IF EXISTS `replace_ci`$$ CREATE FUNCTION `replace_ci` ( str TEXT,needle CHAR(255),str_rep CHAR(255)) RETURNS TEXT DETERMINISTIC BEGIN DECLARE return_str TEXT; SELECT replace(lower(str),lower(needle),str_rep) INTO return_str; RETURN return_str; END$$ DELIMITER ;
Definition at line 39 of file search.class.php.
search::__construct | ( | $ | table, |
$ | opts = null |
||
) |
Constructs a search instance.
string | $table | table name |
mixed | $opts | associative array of options:
|
Definition at line 60 of file search.class.php.
search::clearSearchString | ( | $ | search_string | ) | [private] |
Clear the search string.
Removes words with no meaning
string | $search_string | search string |
Definition at line 76 of file search.class.php.
search::getKeywords | ( | $ | search_string | ) | [private] |
Gets keywords from a search string.
string | $search_string | search string |
Definition at line 97 of file search.class.php.
search::getSearchResults | ( | $ | selected_fields, |
$ | required_clauses, | ||
$ | weight_clauses | ||
) |
Return the search results.
The returned text is an array whose elements are associative arrays with the following keys:
array | $selected_fields | fields to select. Each array element may be the field name or an array:
|
array | $required_clauses | associative array of required clauses in the form array('field_name'=>'field_clause') 'field_clause' may be directly the field value to search for or an associative array specifying the search type (inside, start, end or field) and the value:
|
array | $weight_clauses | associative array of weighted clauses in the form array('field_name'=>'field_clause') 'field_clause' is an associative array:
|
Definition at line 214 of file search.class.php.
search::makeQuery | ( | $ | selected_fields, |
$ | required_clauses, | ||
$ | weight_clauses | ||
) |
Creation of the search query.
array | $selected_fields | fields to select. Each array element may be the field name or an array with the field name as value of the key 'field'. |
array | $required_clauses | associative array of required clauses in the form array('field_name'=>'field_clause') 'field_clause' may be directly the field value to search for or an associative array specifying the search type (inside, start, end or field) and the value:
|
array | $weight_clauses | associative array of weighted clauses in the form array('field_name'=>'field_clause') 'field_clause' is an associative array:
|
Definition at line 128 of file search.class.php.
search::$_registry [private] |
the registry singleton instance
Definition at line 44 of file search.class.php.
search::$_table [private] |
the database table
Definition at line 49 of file search.class.php.