MeNeedz Search User Guide Version 1.0


Search Class

MeNeedz's robust Search Class supports the following features:

Setting Search Preferences

There are 2 different preferences available to tailor how your search should work. You can either set them manually as described here, or automatically via preferences stored in your config file, described below:

Preferences are set by passing an array of preference values to the search init function. Here is an example of how you might set some preferences:

$config['max_age'] = 300;
$this->search->init($config);

Note: All preferences have default values that will be used if you do not set them.

Setting Search Preferences in a Config File

If you prefer not to set preferences using the above method, you can instead put them into a config file. Simply create a new file called the search.php, add the $config array in that file. Then save the file at config/search.php and it will be used automatically. You will NOT need to use the $this->search->init() function if you save your preferences in a config file.

Search Preferences

The following is a list of all the preferences that can be set when performing a search.

Preference Default Value Options Description
max_age300Numeric valueThe maximum age of a search in seconds.
db_configSee belowArray of settings for database usageAn array with all settings that are needed to use the database to cache the search results.
search_configEmpty arrayArray of configs for different searches (See below)An array with all settings that are needed to perform a search.

db_config

A more detailed explanation on the database preferences needed

search_config

A more detailed explanation on the search config needed

Setting up the database

Search Function Reference

$this->search->perform()

Perform a search:

$search = $this->search->perform('test_search', 0, 25);
1. parameter: name of the search as set in your config
2. parameter: offset
3. parameter: row count
Returns an array with the search id, the total number of results and the ids according to your offset, row count and the where parameters used to perform the search on succes and FALSE on failure.

$this->search->scroll()

Scroll search results:

$this->search->scroll(8, 0, 25); 1. parameter: id of the searc
2. parameter: offset
3. parameter: row count
Returns an array with the search id, the total number of results and the ids according to your offset, row count and the where parameters used to perform the search on succes and FALSE on failure.