I've learnt that odbc_execute() does not always trigger a proper ODBC error when it returns FALSE (not at least with the Oracle driver) and I can't fully trust odbc_error() or odbc_errormsg(). This situation is easy to detect when there wasn't a previous error because odbc_error() returns an empty string. However, when it returns something I don't know whether it belongs to the last failed operation or it's a remain from a previous error.
The simplest solution would be to reset the odbc_error() and odbc_errormsg() functions when there's an error so next calls would start from scratch, but I couldn't find a supported way to do so. Can you figure out a way to do it?
Background: I'm enhancing a legacy app with a class that encapsulates database calls. That's why I need to make everything as generic as possible.
it's not necesary to reset the function I solved in this way:
function foo($sql){
   $res = odbc_exec($this->dbconn, $sql);
   if (odbc_error () and $res===false ) {
       return $this->catchException(odbc_errormsg($this->dbconn));
   }
    return $res;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With