< Browse > Home / Web development / Blog article: Show mysql query log with firebug

| Mobile | RSS

Show mysql query log with firebug

December 26th, 2008 | No Comments | Posted in Web development
viswanath.gavva

Replace all mysqlquery() calls in your project to debugmysql_query() to see all mysql queries in Firebug console.In general we use db_query function.so we need to change the mysql_query() in db_query() to debugmysql_query().

add the following function in the same page where we wrote db_query function .

if (!function_exists(’debug_mysql_query’)) {

function debug_mysql_query($query)
{
$js_query = str_replace(array(’\\’, “‘”), array(”\\\\”, “\\’”), $query);
$js_query = preg_replace(’#([\x00-\x1F])#e’, ‘”\x” . sprintf(”%02x”, ord(”\1″))’, $js_query);
echo ‘<script>console.log(”‘.$js_query.’”);</script>’.”\n”;
return mysql_query($query);
}
}

Now go to your firefox browser and access any page.you can see the queries in console tab in firebug .

Leave a Reply 500 views, 1 so far today |
  • No Related Post

Leave a Reply

You must be logged in to post a comment.