Skip to content

Conversation

@bengro
Copy link

@bengro bengro commented Apr 19, 2014

I extended the functionality the current version of php-rest-sql by the following:

  • Paging: when tables consist of thousands of rows, it makes sense to use paging to avoid massive responses. By using the GET parameters page and per_page, the data can be retrieved with paging. per_page can be additionally set in the config file. When these parameters are not set, the preset value in config is used.
  • Sorting / searching: The table content can now be searched and sorted using GET parameters. E.g. /table?orderby=col1&col1=<1 retrieves all rows for which col1 < 1 ordered by col1 ASC. The supported operators are <, >, =, ~ (LIKE). When there are multiple search criteria, they are concatenated with AND.

In order to facilitate the above enhancements I had to restructure the code dealing with GET method, and add a url parser which parses the URL and returns the comprised directories and GET parameters.

The new features only work with the MySQL adapter; as I cannot do not know / test Postgres and MSSQL. Yet, I made sure the new code does not break the other adapters - the simply do support the new features.

This enhancement resolves issues:
#1
#4

I deliberately did not touch the other HTTP methods (POST, PUT, DELETE), or the rendering of the content.

@mehdic
Copy link

mehdic commented Apr 25, 2015

Can you provide usage examples ? especialy for the LIKE clause, how do you use ~ with a string aftewards? ( a string with a whitespace maybe ?).

and thanks for the help. this was exactly what i was looking for.

@bengro
Copy link
Author

bengro commented Apr 26, 2015

In the description you can find an example of using ordering and sorting (=<, => operators).

An example for the LIKE clause would be:
/table?col1=~This%20is%20a%20String
(You must encode the whitespaces as %20, or +.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants