Note the upgraded forum! If you are experiencing issues logging in, you may need to reset your password which should send an email. If the email doesn't arrive, be sure to check your spam folder just in case.

Proposed change to debug_query()

Hi

I find debug_query() to be a very useful tool but it can be confusing when used since the default behaviour is to echo the result to the page. With a complex page with debug_query() scattered around, it can be difficult to see which query is which when just dumped to the top of the page.

I've fixed this for myself by adjusting the core function slightly:

In ./fuel/core/MY_Model.php
public function debug_query($hidden = FALSE, $exit = FALSE, $return = FALSE) { $str = $this->db->debug_query($hidden, $exit, $return); if(!empty($return)) { return $str; } }

and in ./fuel/core/MY_DB_mysql_driver.php
public function debug_query($hidden = FALSE, $exit = FALSE, $return = FALSE) { $str = ''; if (!empty($hidden)) echo '<!--'; $str.= $this->last_query()." \n"; if (!empty($hidden)) $str.= '-->'; if (!empty($return)) { return $str; } else { echo $str; } if (!empty($exit)) exit; }

In guess the same changes would need to be made for the other drivers too...

Comments

  • edited 1:08AM
    Great suggestion... I'll look into adding that.
Sign In or Register to comment.