fdbweblogroute Log SQL queries to web page and beautify the SQL a bit

  1. Requirements
  2. Usage

The FDbWebLogRoute is a CWebLogRoute extension solely for logging SQL queries. While you can log ALL the SQL using Yii profiling (See http://www.yiiframework.com/doc/guide/1.1/en/topics.logging#profiling-sql-executions) this could be prettier with FDbWebLogRoute because the profiler always gives you a start and a end log for each query. It means you see one query twice.

This logroute also use Google code prettier JS library to beautify the SQLs a bit. Some color and highlighting to save your eyes.


Google code prettier library. This is not distributed with the extension. Download is here: http://code.google.com/p/google-code-prettify/


The intension of this extension is for debugging your SQL. If you need profiling, identify the bottleneck SQL, do use Yii profiling.

To log a query:


Same way of dbLogBegin/End wrapping your code to log all queries executed in the code block. i.e. put these function at the begin and end of your controller's action.


Put this file under extensions/logging/ folder

Put Google code prettify library under extensions/scripts/code.prettify (rename the 'src' folder in your download by 'code.prettify'). If this is not what you want, edit line #58, #59 in FDbWebLogRoute.php


// db component in config/main.php
        'db' => array(
            'enableProfiling'=>true, //optional, if you also need profiling
            'enableParamLogging'=>true, //to show parameter values
// log component in config/main.php
        'log' => array(
            'class' => 'CLogRouter',
            'routes' => array(
                'dbLog' => array(
                    'class' => 'ext.logging.FDbWebLogRoute', //if you put this file under extensions/logging/ fodler
3 1
Yii Version: 1.1
License: (not set)
Category: Logging
Tags: db, log, sql log
Developed by: Hudson Nguyen
Created on: Dec 30, 2010
Last updated: 10 years ago


show all

Related Extensions