Skip to content

Commit cefe89a

Browse files
committed
Last commit before first release.
1 parent d057c86 commit cefe89a

File tree

3 files changed

+52
-6
lines changed

3 files changed

+52
-6
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to
66
[Semantic Versioning](http://semver.org/).
77

8-
## [1.0.0] - 2017-06-XX
8+
## [1.0.0] - 2017-08-01
99

1010
* Initial release.

README.md

+51-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
## Sample with not in
1313

14-
Suppose you have a Web Service accessible using `https://api.myserver.com/users` and you want to create a filter to find
14+
Suppose you have a Web Service accessible using `https://api.myserver.com/users` and want to create a filter to find
1515
users not having a first name equals to `Jack`, `Joe`, `Willian` or `Averell`.
1616

1717
To do this you'll have to request your relationnal database with a `not in` SQL request. The `php-value-filter-dsl`
@@ -43,6 +43,7 @@ $sqlFilter = $this->filterConverter->transform($urlParameterName, $urlParameterV
4343
// Use the parsed result to build our SQL query
4444
$preparedStatement = $pdo->prepare('select * from users where ' . $sqlFilter->getExpression());
4545

46+
// Bind our prepared statement parameters
4647
$i = 1;
4748
foreach($sqlFilter->getParams() as $param) {
4849
$preparedStatement->bindParam($i++, $param);
@@ -57,12 +58,58 @@ prepared statement parameters `Jack`, `Joe`, `Willian`, `Averell`.
5758

5859
Very simple and useful, isn't it ?
5960

60-
Please note that for now we only provide convertion of our filters into SQL, but will extend the library to provide
61-
additional converters to transform the filters into other formats.
61+
Please note that for now we only provide convertion of filter expressions in SQL. Later we'll extend the library to
62+
provide additional converters to transform the filters into other formats.
6263

6364
## Documentation
6465

65-
In progress.
66+
### Standard operators
67+
68+
The expression language provides the following operators.
69+
70+
| Operator | ASCII value | Name | Value type(s) |
71+
|----------|-------------|--------------------------|----------------------------------------|
72+
| `=` | `%3D% | Equals | Integer, Float, String |
73+
| `<` | `%3C` | Less than | Integer, Float |
74+
| `<=` | `%3C%3D` | Less than or equal to | Integer, Float |
75+
| `>` | `%3E` | Greater than | Integer, Float |
76+
| `>=` | `%3E%3D` | Greater than or equal to | Integer, Float |
77+
| `in` | | In | Integer list, Double list, String list |
78+
| `~` | `%7E%` | Like | String |
79+
| `!` | | Not | _see description above_ |
80+
81+
### Not operator
82+
83+
The `!` operator is special, it can be used directly before a value string or in combination with the `=` or `in`
84+
operators.
85+
86+
For exemple `!5` or `!=5` to express "no equals to 5" or `!in('Paris','London')` ro express "no equals to Paris or
87+
London".
88+
89+
### Like operator
90+
91+
The `~` operator allows to create like SQL requests, but it is always converted to expressions equals to
92+
`my_property like ?` with a value equals to `%word%` which is not always wanted.
93+
94+
To express more complex like expressions you can use the `*` string operator in the value associated to the `=` or `~`
95+
operators.
96+
97+
For example `property=~'*Nantes*France*'` or `property='Nantes*France*'` will be translated to `property like ?` with
98+
a parameter equals to `%Nantes%France%`.
99+
100+
### Values
101+
102+
The following values can be used.
103+
104+
* `null`
105+
* `true`, converted to the string "true" if the associated property is a string, to 1 if the property is an integer and
106+
to 1.0 if the property is a double
107+
* `false`, converted to the string "false" if the associated property is a string, to 0 if the property is an integer
108+
and to 0.0 if the property is a double
109+
* integer
110+
* floting number
111+
* string (must be quoted with simple quotes ')
112+
* string with an ISO 8601 format for the dates
66113

67114
## About Gomoob
68115

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"name": "php-value-filter-dsl",
3-
"version": "1.0.0-alpha1",
43
"license": "MIT",
54
"repository": {
65
"type": "git",

0 commit comments

Comments
 (0)