This is the code for printing last excuted query in codeigniter is
print_r($this->db->last_query());
As like what is the code for printing last executed query in PHP?
This is the code for printing last excuted query in codeigniter is
print_r($this->db->last_query());
As like what is the code for printing last executed query in PHP?
You could do something like this to get last executed query:
$mysql_last_query = ""; //this var contains the last mysql query function query($sql, $args) { #sintax: query("query", "arg1", "arg2", "argn"); EXAMPLE: query("select * from %s", $_GET["table"]); global $mysql_last_query; $args = func_get_args(); if(($num = func_num_args()) > 1) $sql = call_user_func_array("sprintf", $args); $mysql_last_query = $sql; return mysql_query($sql); } function select($table, $what = "*", $where = "", $limit = ""){ #this function is a "shortcut" for mysql select EXAMPLE: select("blah"); //SELECT * FROM blah and so on return mysql_query("SELECT ".$what." FROM ".$table.($where == "" ? "":(" WHERE ".$where)).($limit == "" ? "":(" LIMIT ".$limit))); }
Hope it helps
This is a seemingly common question. The intended way to do it seems to depend on logging: How to show the last queries executed on MySQL?