我正在尝试在我的第一个严重的CodeIgniter应用程序中调试一些代码,我似乎无法找到我可以简单地获取我的ActiveRecord代码刚刚生成的原始SQL的位置.
$where = 'DAY(`datetime_start`) = '. date('d',$day) .' AND ';
$where .= 'MONTH(`datetime_start`) = '. date('m',$day) .'';
$this->db->from('events')->where($where);
$result = $this->db->get();
Run Code Online (Sandbox Code Playgroud)
谢谢您的帮助!
hip*_*ker 43
在查询运行之前:
$this->db->_compile_select();
Run Code Online (Sandbox Code Playgroud)
运行之后:
$this->db->last_query();
Run Code Online (Sandbox Code Playgroud)
当然,我发现它发布后2分钟,由Phil Sturgeon提供.
echo $this->db->last_query();
Run Code Online (Sandbox Code Playgroud)
此外,您可以将以下内容放在您的控制器中:
$this->output->enable_profiler(TRUE);
Run Code Online (Sandbox Code Playgroud)
你会得到更多的疑问.