Created
December 5, 2020 21:46
-
-
Save ademalp/34a363cd1c9393cd9aa1255ef05f7b1a to your computer and use it in GitHub Desktop.
Codeigniter Hook Db Log
This file contains 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 | |
class Db_log{ | |
public function queries(){ | |
$CI = &get_instance(); | |
$filename = APPPATH."logs/queries-".date("Y-m-d").".php"; | |
$queries = $CI->db->queries; | |
$times = $CI->db->query_times; | |
foreach($queries as $k => $v){ | |
$queries[$k] = date("Y-m-d H:i:s")." - ".$times[$k]." : "."$v;\n"; | |
} | |
$queries = implode("",$queries ); | |
file_put_contents($filename, $queries, FILE_APPEND); | |
} | |
} |
This file contains 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
$hook['post_controller'] = array( | |
'class' => "Db_log", | |
'function' => "queries", | |
'filename' => "Db_log.php", | |
'filepath' => "hooks" | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment