[eluser]xwero[/eluser]
I just did a bit a checking and the methods _compile_select, _insert, _update, _truncate and _delete can be used to retrieve the sql statement but then all the parts of the sql statement have to be declared before the action method so instead of writing
Code:
$query = $this->db->get('table');
You have to write
Code:
$this->db->from('table');
$query = $this->db->get();
If you follow this rule you can use following helper
Code:
// helpers/db_debug.php
<?php
function show_select()
{
$CI =& get_instance();
return $CI->db->_compile_select();
}
function show_insert()
{
$CI =& get_instance();
return $CI->db->_insert();
}
function show_update()
{
$CI =& get_instance();
return $CI->db->_update();
}
function show_truncate()
{
$CI =& get_instance();
return $CI->db->_truncate();
}
function show_delete()
{
$CI =& get_instance();
return $CI->db->_delete();
}