如何在 Windows 和 Linux 中获取我在 MySQL 中运行的最后一个查询?
我正在使用 PHP 和 CodeIgniter。在 my_model.php
中,我有:
$query1 = ( ...something... );
$query2 = ( ...something... );
$variables = ( .... something .... );
$this->db->query(" $query1 ... $variables .. $query2", array( $variables, ... ));
我需要在上面的代码片段之后执行的最后一个查询。
谁能告诉我怎样才能得到我的最后一个查询?
最佳答案
使用:
$this->db->last_query();
Returns the last query that was run (the query string, not the result). Example:
$str = $this->db->last_query();
// Produces: SELECT * FROM sometable....
示例取自 query helper functions 上的手册
关于php - 使用 PHP/CodeIgniter 在 MySQL 中获取最后执行的查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6536431/