Table of Contents

## Searching and Filtering

When users clicks on the search icon, a search screen will appear where they can search for text strings and numeric values. In the following example, you can search from a popup, use checkboxes to select multiple "Or" criteria to search on, and enter search criteria in a text box. You can see that we can also search for all products with less than 10 units in stock. All text boxes allow you to enter comparison operators (=, !=, <>, <, >, <=, >=).

You can search for dates using the format defined by the dateInput property. Two digit years will wrap around correctly.

### Searching by Range

You can perform range searches using the words to and until since phpLens 2.6.0. For example to search from 10 to 20, you many enter either:

    10 (to) 20
    10 (TO) 20
    10 (until) 20

To search for all countries from Argentina to Nigeria you can use either:

    Argentina (to) Nigeria
    Argentina (until) Nigeria
    Argentina(TO)Nigeria

The words used to identify a range is controlled by the language array $lens->lang->betweenTxt (defined in the language file phplens-lang-??.inc.php). You can override this to use your own language. For example, in Bahasa Malaysia, we can set it to:

    $lens->lang->betweenTxt = array('(ke)','(hingga)'); // ke==to, hingga==until

Words in the array must be in lower-case and enclosed in brackets.

We still support the old >< operator. To search for all countries from Argentina to Nigeria, use:

    >< Argentina,Nigeria

This will generate a query where 'Argentina' <= Country and Country <= 'Nigeria'.

### Searching with Match Anywhere

You can specify that a particular field searches using match anywhere, overriding the default match settings using the =% operator. For example, to search for the name PISTON anywhere in a particular field, enter:

=%PISTON

Whether the search is case-sensitive or not depends on the database.

### Searching using NOT LIKE

If you search on a text field and the first character begins with ! (and does not match !=):

    !APPLE

will generate the following SQL:

    SELECT * FROM TABLE WHERE FIELD NOT LIKE 'APPLE%'

### Find More

The Find More checkbox controls whether fields are ANDed or ORed when searching. When Find More is enabled, we OR the fields, resulting in a larger set of filtered records. When disabled, we AND the fields. This is equivalent to the filterAllOr property. The checkbox has been available since phpLens 2.6.0.

To enable Find More, you must set $lens->showFindMore = true.

### Configuring Search

The following configuration screen is diplayed when you click on the white Supplier icon. Note that Use Checkboxes is enabled. The filter hint is taken from the lookupLens settings, but is not applied in the search screen automatically so that you can choose whether to display a text box or popup.

How Do I... | Solution | Property modified
Decide on which fields to display | Click on the green icon to see the Filter Columns screen. Then move the fields from left to right to display, and right to left to hide. | filterLens
Change the field title | Click on the white icon for the field you want to modify and change that field's title. | nameLens
Use a popup instead of a text field | Click on the white icon for the field you want to modify and set theFilter Options you want for the popup. | filterParams
Use checkboxes | Click on the white icon for the field you want to modify and enable the Use Checkboxes. | filterParams
Change default string search matching | You want to change the default from Match From Beginning (1) to Match Exactly(0) or Match Anywhere(2). Set the filterUseLike property programmatically. | filterUseLike
Start phpLens with the search screen | Click on the green icon to see the Filter Columns screen. Click on phpLens Settings at the top of the screen. Scroll past the color settings, and set Start phpLens to Search Form. | firstState
Hide the search form once a search is initiated | Set the filterShowForm property to false. | filterShowForm