Jump to content

restrict call to mysql_query() function


Vikas Jayna

Recommended Posts

I am trying to make a middle layer for interaction between the database and the applications

 

Hence I created a function _db_query() that is to be called to execute any query throughout the application on our site. This function does some decision making about which server the query should go to. The function uses mysql_query() function then to execute the query on that server. The issue is that I need to restrict the use of mysql_query() function from anywhere else in the application and force them to use the function _db_query() so as to avoid mistakes in case a programmer forgets to call _db_query() and instead calls mysql_query()

 

Any ideas about implementing this?

Link to comment
https://forums.phpfreaks.com/topic/84998-restrict-call-to-mysql_query-function/
Share on other sites

I'm actually not sure it can be done. You cannot overide a function in php and while you can disable functions, that disables the function install wide.

 

One thing you could do would be to hide the user/pass, making it impossible to connect to a database unless calling the _db_query function which would then also need to handle the connection.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.