• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to check for sql syntax error

#1
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...
Reply

#2
Maybe this will help:
http://stackoverflow.com/questions/32345...ysql-error
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.