Skip to content

Instantly share code, notes, and snippets.

@jyokyoku
Created July 9, 2011 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jyokyoku/1073579 to your computer and use it in GitHub Desktop.
Save jyokyoku/1073579 to your computer and use it in GitHub Desktop.
CakePHP DboMysqlLog
<?php
App::import('Datasource', 'DboSource');
App::import('Datasource', 'DboMysql');
class DboMysqlLog extends DboMysql
{
function execute($sql, $options = array()) {
$defaults = array('log' => ($this->fullDebug || Configure::read('Sql.log')));
$options = array_merge($defaults, $options);
return parent::execute($sql, $options);
}
function logQuery($sql) {
$return = parent::logQuery($sql);
if (Configure::read('Sql.log')) {
$this->log($sql, 'sql');
}
return $return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment