title: logging all queries after execution in codeigniter
body: <p>i want to log all queries after execution using hooks.
  -i enabled hooks in config.php
  -this is my hook--></p>
  
  <pre><code> $hook['post_controller'] = array(    
      'class' =&gt; 'Db_log',             
      'function' =&gt; 'logQueries',     
     'filename' =&gt; 'db_log.php',    
     'filepath' =&gt; 'hooks'         
    );
  </code></pre>
  
  <p>-and this is hook defination--></p>
  
  <pre><code>class Db_log 
  {
  
      function __construct() 
      {
      }
  
  
      function logQueries() 
      {
          $CI = &amp; get_instance();
  
          $filepath = APPPATH . 'logs/Query-log-' . date('Y-m-d') . '.php'; 
          $handle = fopen($filepath, "a+");                        
  
          $times = $CI-&gt;db-&gt;query_times;
          foreach ($CI-&gt;db-&gt;queries as $key =&gt; $query) 
          { 
              $sql = $query . " \n Execution Time:" . $times[$key]; 
  
              fwrite($handle, $sql . "\n\n");    
          }
  
          fclose($handle);  
      }
  
  }
  </code></pre>
  
  <p>--its creating query_log file
  --but no records of queries being stored</p>