I need to audit the insert, edit and delete queries from my application, I tried using a hook that calls a model that save the query into a table in my database, however it is just saving the SHOW, DESCRIBE and SELECT statements, but the update, adding and deleting actions that I perform on the GroceryCrud views are not being saved.
Can someone help me to figure it out why, Thanks!
<?php /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ ?> <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class Save { private $ci; public function __construct() { $this->ci = & get_instance(); !$this->ci->load->library('session') ? $this->ci->load->library('session') : false; !$this->ci->load->helper('url') ? $this->ci->load->helper('url') : false; } public function save_queries() { $CI = & get_instance(); $filepath = APPPATH . 'logs/Query-log-' . date('Y-m-d') . '.php'; // Creating Query Log file with today's date in application/logs folder $handle = fopen($filepath, "a+"); // Opening file with pointer at the end of the file $times = $CI->db->query_times; // Get execution time of all the queries executed by controller foreach ($CI->db->queries as $key => $query) { $sql = $query . " \n Execution Time:" . $times[$key]; // Generating SQL file alongwith execution time fwrite($handle, $sql . "\n\n"); // Writing it in the log file } fclose($handle); // Close the file } } /* /end hooks/home.php */