CodeIgniter Forums

Full Version: how to check for sql syntax error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This is the code

      $q = $this->db->query($sql);
      if ($q === FALSE)
        //throw new Exception($this->db->error);  
        throw new Exception('stupid error'); 


It does not work. All that happen is the error is logged by codeignitor and the script is dead at that point. What am I doing wrong?

I may have posted a similar question earlier but I cannot locate it.

UPDATE: I have fixed the problem by modifying some apparently bad code in DB_driver.php that was causing the script to blow up when it attempted this: $this->display_error(array('Error Number: '.$error['code'], $error['message'], $sql))
I commented that line out so that query() will return FALSE if the SQL fails. Works fine for me now anyway...