I'm thinking on a way to secure a PHP application. I would like to set up a user with limited rights on the database server side (MySQL), and configure this user in the PHP application for all database requests.

Now the problem is that someone who could have access to the source files (for example an employee) can uses the configured credentials to directly connect to the database (for example via phpmyadmin). The database should be updated only through the PHP application.

I would like to set up a mechanism (trigger or whatever possible on mysql side or php side or both) which checks from which client a request to the database come from, thus ignoring it or not. Is it possible to do that? Are there others ways to consider this problem?

Regards