如何知道对数据库进行了什么查询并在php中返回?

A php code sent a query to the database say credentials from login page for verifying and something was returned say TRUE OR FALSE as status. Now my question is, if I do not know the code of the developer who wrote the login form, does there exist any way to find out what query is made to the database OR what has been returned by the database? Since I'm unaware of the developer's code which means I'll need a parallel script working in parallel with the login form. Can I also do that? The reason why I asked this question is I just want to sanitize the output data from the database as being a little paranoid, I can't trust the data coming from the database. Some XSS issue, nothing more.

if you are using codeignitor then, To enable the profiler place the following function anywhere within your Controller functions:

$this->output->enable_profiler(TRUE);

for more help : http://ellislab.com/codeigniter/user-guide/general/profiling.html