Closed challgren closed 4 years ago
There is two existing ways of solving this problem:
delegateSearch
option and have your ORM Table's finder interpret/reformat the search stringBoth have the advantage that the controller doesn't have to deal with it. How the search string is formatted and interpreted is not a matter to the controller but to the client and/or the model.
What do you think about the proposed solutions?
I never thought of those options. But so here's one case where client side would be a bad option. For example since there is no maxLength set a client could potential request length to -1 or a number that would kill the database. Right now none of my tables are publicly facing but once exposed I wouldn't want to give users the option to have a limit greater than one I specify. So for now my solution is to modify the query parameters before the component works on it.
I understand the concern to limit these parameters as when you request a huge amount of records, not only will it be a strain on the database, but also json_encode()
can eat up quite some CPU time as well.
Maybe we should have a member query
in the component with a setter for it and, if unset, in find() we use the request to set it?
Since CakePHP version 4.0 is going to make the Request object protected, it would be nice to have the option to pass the query parameters ourselves so we can modify them prior to the component running.
Use case
User doesn't understand that
%
is really a*
so I would like to have the option to replace all*
's with%