-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
51 lines (36 loc) · 1.52 KB
/
README
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
searchParser: Class to parse search term strings.
version 0.5.0
Marty Vance
15 Oct 2010
License: GNU GPL v2: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
This is a search string parser I started writing because I couldn't find one
with the features I wanted. It's not complete yet: see TODO below.
Features:
Support for unary operators (+/-). Plus is always assumed if - is not
present.
Localized support for boolean operators (AND/OR).
Support for field identifiers (title:foo).
Localized support for quote and apostrophe characters.
Constructor args:
$q: array of quote characters
$a: array of apostrophe characters
$n: array of boolean AND operator strings
$o: array of boolean OR operator strings
Public methods:
__get($name): returns the value of a member variable
setString($string): takes a string as an arg. Returns bool true if the
arg is a string of > 0 length after parsing it, or returns false.
dumpPhrases(): returns a formatted string of the elements found in the
previously given search string.
getWhere($fields): takes an array of database field identifiers and returns
an SQL where clause suitable for use in queries.
TODO:
- Finish private function construct(): this is where the flat list of
pieces assembled in parse() get nested into a structure more representavive
of the user's intent.
- Error/exception handling.
- Support for unmatched (left/right) quote characters.
- Default constructor arg values suitable for English (?).
- Support for parethetical grouping.
Version history:
- 0.5.0: initial release.