Created
July 7, 2015 21:04
-
-
Save rsanchez/b84208c586927ebd39db to your computer and use it in GitHub Desktop.
EE log sql queries to file
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
<?php | |
function _execute($sql) | |
{ | |
$sql = $this->_prep_query($sql); | |
### HACK START | |
$is_write = preg_match('/^(insert|update|delete|alter|create|drop)/i', $sql); | |
$ignore_tables = array( | |
'exp_stats', | |
'exp_security_hashes', | |
'exp_sessions', | |
'exp_cp_log', | |
'exp_developer_log', | |
'exp_site_bootstrap_checksums', | |
'exp_zenbu_filter_cache', | |
'exp_assets_index_data', | |
'exp_last_activity', | |
'exp_channel_entries_autosave', | |
); | |
$is_ignored = preg_match('#'.implode('|', $ignore_tables).'#', $sql); | |
if ($is_write && ! $is_ignored) | |
{ | |
$handle = fopen(FCPATH.DIRECTORY_SEPARATOR.'query-log.sql', 'a+'); | |
fwrite($handle, '###'.PHP_EOL.PHP_EOL.$sql.';'.PHP_EOL.PHP_EOL); | |
fclose($handle); | |
} | |
### HACK END | |
return @mysql_query($sql, $this->conn_id); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment