Search in This Blog

Show sql query in Codeigniter


While working in Codeigniter framework and execution some sql query. but the sql query result is not coming as you want. In this case there are something wrong with your sql queries. Then what you will do? the answer is that you will see the what exact sql query you are executing in Codeigniter.
So how can you show or see sql query in Codeigniter?

you can use this statement after execution sql query

you can use $this->db->last_query();  statement as below:


$sql = "SELECT district_id FROM district_names where districtname= ?";
$rsMatter=$this->db->query($sql, array($districtname));
echo $this->db->last_query();