Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
I'm writing a system that will allow a restful api consumer to lightly modify/restrict a query in a way that dose not require the author of a model to account for with any special behavior. The $crub object would be passed to a class that would auto-manipulate the query using passed url query parameters.
The proposed url query format would be like (w/ whitespace for readability):
While some params are simple to implement (i.e. adding a limit/offset is as simple as parsing their value and calling $select->limit($limit)) there are others that are proving quite difficult. Ignoring property visibility in sqlqury's CRUD classes, here are some of situations encountered.
Given the following sql query:
foowill cause mysql to complain of ambiguity$filter[]=yellow.col2|=|hot), while removing ambiguity, violates the law of Leaky Abstraction. Additionally, it causes some headaches when trying to escape the user-supplied values by usingbindValue()where()limits filters to the main table, restricting columns from a join from being filtered$fieldsrequests is extremely difficult to do accurately without a complex convention (and even then).Solution
The proposed solution would be to allow columns to be aliased for further reference. By way of example, here is what the api would look like:
This syntax will allow for any aliased field to be simply omitted from the query (a new
removeCol()method will be necessary), and will allow for greater intelligence when trying to filter queries:foo) which can then be resolved toyellow.fooby looking up the real field name in the$colsarray.$select->removeCol($alias))$fieldslimitation.I'm also open to other suggestions on how to go about this issue.