Skip to content

Instantly share code, notes, and snippets.

@jaggy
Last active August 29, 2015 14:00
Show Gist options
  • Save jaggy/11368249 to your computer and use it in GitHub Desktop.
Save jaggy/11368249 to your computer and use it in GitHub Desktop.
Log CakePHP 2.x queries. Line 455
$references = array(
'SELECT' => 'yellow',
'deleted' => 'red',
'DELETE' => 'red',
'UPDATE' => 'blue',
'INSERT' => 'green',
);
$excludes = array('SHOW FULL COLUMNS', 'Aro', 'Aco', 'Permission', 'SHOW TABLES', 'SELECT CHARACTER_SET_NAME', 'SELECT COUNT');
$print = true;
$color = 'magenta';
foreach ($excludes as $exclude) {
if (strstr($sql, $exclude)) {
$print = false;
break;
}
}
foreach ($references as $keyword => $update) {
if (strstr($sql, $keyword)) {
$color = $update;
break;
}
}
if ($print) {
$display = strstr($sql, 'FROM');
CakeLog::write('error', "<{$color}>{$display}</{$color}>");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment