Get last executed query in MySQL with PHP/CodeIgniter

Viewed 100868

How can I get last query I ran in MySQL in both Windows and Linux?

I am working with PHP and CodeIgniter. In my_model.php, I have:

$query1 = ( ...something... );
$query2 = ( ...something... );
$variables = ( .... something .... );
$this->db->query(" $query1 ... $variables .. $query2", array( $variables, ... ));

I need the last query executed right after the code snippet above.

Can anyone tell me how can I get my last query?

3 Answers

In the config/database.php the config array must be set: 'save_queries' => TRUE, if it is false not working the last_query() function.

Related