How to print SQL statement in codeigniter model

前端 未结 14 1988
迷失自我
迷失自我 2020-11-30 22:08

I have a sql statement in my model,

I then say

$query = $this->db->query($sql, array(fields, fields1);

if ($query) {
    return true:
} else {         


        
14条回答
  •  我在风中等你
    2020-11-30 22:33

    To display the query string:

    print_r($this->db->last_query());    
    

    To display the query result:

    print_r($query);
    

    The Profiler Class will display benchmark results, queries you have run, and $_POST data at the bottom of your pages. To enable the profiler place the following line anywhere within your Controller methods:

    $this->output->enable_profiler(TRUE);
    

    Profiling user guide: https://www.codeigniter.com/user_guide/general/profiling.html

提交回复
热议问题