Your approach has a lot of problems. Anyone can reverse engineer your protocol and execute any query they want on your SQL server. Thus, your data is not only readable, but can be changed by anyone. In other words, you will be hacked.
The usual way is to split the cake into layers. This means defining an API built from clear and well-defined methods, with input parameter types, return values ββand permissions.
This API can be implemented in any way: jsonrpc, SOAP, xmlrpc, your choice, even an HTTP GET for the returned php script jp file.
The latter option is a bit awkward, but also nice, as it allows you to use the same api from javascript running inside your site. There is no need to have two competing APIs.
Example:
API get_user_profile (user_id INT);
INPUT: integer user id
RETURNS: row in table users for this user, depending on their permissions.
Since the API is executing inside an authenticated session (using cookies or something else), it knows that the user is making a request. Thus, it will allow the user to see their phone number / email, but he will not return these fields to other users, unless they are administrators (which, of course, is possible with a simple example of permissions, more complex).
Thus, each operation requires its own API. Some of them are complex, for example, general search. Instead of writing your own mini-language and manipulating parameters to specify search parameters, you can simplify the situation by making it more or less look like a website. The client sends everything that the user enters into the search fields to the server (for example, an HTTP form), and the server decides how to deal with it.
Obviously, if any parameters of your API are directly inserted into SQL queries, then SQL injection means that you are also hacked. Therefore, you need to do it right, like on any website, everything that is exposed to malicious Internet is constantly attacked.
Think of the client as a browser, API calls as URLs, forms, xmlhttprequest, etc., and the server as PHP or any other server language. This is basically what it is.