duanhe2027 2018-10-05 11:29
浏览 89
已采纳

获取codeigniter中所有数据库查询的列表(在ajax请求中)

I'm using codeigniter

now my ajax request its very slow and I want to find the reason

in ajax request, I want to save all DB query in a log file

it's possible?

  • 写回答

2条回答 默认 最新

  • douzong5057 2018-10-05 11:40
    关注

    you can turn on db loging in config file:

    $db['default'] = array(
       ...
       'save_queries' => TRUE
       ....
    );
    

    then end of ajax request use $queries = $this->db->queries; to get all SQL query

    $log .= join("
    ",$this->db->queries);
    $myfile = file_put_contents('logs.txt', $txt.PHP_EOL , FILE_APPEND | LOCK_EX);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?