I am creating a api for my web app which would be open source and users will be able to host it on there on websites, with this api users will be able to create tools for there own copy of the open source website and download and use other people tools. For the api I am thinking about letting the users query to the database using SQL for example if they want to get the name of something they would right a sql query using a JavaScript api wrapper and it would be sent to a PHP file to run the SQL query. For security purposes. the users are limited to query to a specific amount of tables and each time a key would be needed for querying
I want to know if this approach is secure as I don't want my users to be hackable like against the SQL injection.