Return to Snippet

Revision: 7924
at August 21, 2008 08:55 by stancell

Initial Code
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);

Initial URL

Initial Description
Replace all mysql_query() calls in your project to debug_mysql_query() to see all mysql queries in Firebug console.

Initial Title
Show mysql query log with firebug

Initial Tags
mysql, log, query

Initial Language