Last active
August 29, 2015 14:00
-
-
Save jaggy/11368249 to your computer and use it in GitHub Desktop.
Log CakePHP 2.x queries. Line 455
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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