Anyone aware of an issue of where the db2_execute statement can return true
if the statement fails on IBM i? I have a class wrapped around the
db2_execute statement and I test for it to return false.  If it does, I
take steps to log the failing statement, the parameters, etc. Problem is, I
have an instance where I am getting notices in the PHP error log file that
db2_execute failed, but I am not seeing any logged information.  One way
this would happen is if db2_execute failed and still returned true.
I wouldn't even ask this it I wasn't aware of an old (unrelated) bug in the
db2 extension that actually caused that to happen (see
http://pecl.php.net/bugs/bug.php?id=13185).
I have tested this several times by intentionally causing an error, and so
far the logging occurs as it should.  Having a very difficult time figuring
out why this would not work:
class Db2Class {
    // other properties and functions
    public function executeSql($sqlstmt, $parms)
    {
        // code snipped
        // prepare SQL statement
        $this->_stmt = db2_prepare($db2conn, $sqlstmt);
        if ($this->checkResult($this->_stmt, $db2conn, $sqlstmt, $parms)) {
            // if statement was prepared
            if ($this->_stmt) {
                $result = db2_execute($this->_stmt, $parms);
                if ($this->checkResult($result, $db2conn, $sqlstmt,
$parms))
                    return $this->_stmt;
                }
                else {
                    return false
                }
            }
        }
    }
    public function checkResult($result, &$sqlconn = null, $sqlstmt = '',
$sqlparms = array())
    {
        if ($result === false) {
            // code snipped - log everything
            // in some cases there is error message in php_error_log but
nothing here executed.
            return false;
        } else {
            return true;;
        }
    }
}
 
As an Amazon Associate we earn from qualifying purchases.