php-rest-sql icon indicating copy to clipboard operation
php-rest-sql copied to clipboard

Enhancements and issues fixed

Open bengro opened this issue 11 years ago • 2 comments

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: https://github.com/peej/php-rest-sql/issues/1 https://github.com/peej/php-rest-sql/issues/4

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

bengro avatar Apr 19 '14 14:04 bengro

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.

mehdic avatar Apr 25 '15 17:04 mehdic

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 +.)

bengro avatar Apr 26 '15 09:04 bengro