irm-1.6-b3/MDB/ibase.php
/**
     * Map native error codes to DB's portable ones.  Requires that
     * the DB implementation's constructor fills in the $errorcode_map
     * property.
     *
     * @param $nativecode the native error code, as returned by the backend
     * database extension (string or integer)
     * @return int a portable MDB error code, or FALSE if this DB
     * implementation has no mapping for the given error code.
     */
Map native error codes to DB's portable ones.  Requires that
the DB implementation's constructor fills in the $errorcode_map
property.

@param $nativecode the native error code, as returned by the backend
database extension (string or integer)
@return int a portable MDB error code, or FALSE if this DB
implementation has no mapping for the given error code.
Map native error codes to DB ' s portable ones . Requires that the DB implementation ' s constructor fills in the $errorcode_map property . @param $nativecode the native error code as returned by the backend database extension ( string or integer ) @return int a portable MDB error code or FALSE if this DB implementation has no mapping for the given error code .
function errorCode($errormsg)
    {
        if (preg_match('/^([^0-9\-]+)([0-9\-]+)\s+(.*)$/', $errormsg, $match)) {
            $errno = (int)$match[2];
        } else {
            $errno = NULL;
        }
        switch ($errno) {
            case -204:
                if (is_int(strpos($match[3], 'Table unknown'))) {
                    return MDB_ERROR_NOSUCHTABLE;
                }
            break;
            default:
                if (isset($this->errorcode_map[$errno])) {
                    return($this->errorcode_map[$errno]);
                }
                static $error_regexps;
                if (empty($error_regexps)) {
                    $error_regexps = array(
                        '/[tT]able not found/' => MDB_ERROR_NOSUCHTABLE,
                        '/[tT]able unknown/' => MDB_ERROR_NOSUCHTABLE,
                        '/[tT]able .* already exists/' => MDB_ERROR_ALREADY_EXISTS,
                        '/validation error for column .* value "\*\*\* null/' => MDB_ERROR_CONSTRAINT_NOT_NULL,
                        '/violation of [\w ]+ constraint/' => MDB_ERROR_CONSTRAINT,
                        '/conversion error from string/' => MDB_ERROR_INVALID_NUMBER,
                        '/no permission for/' => MDB_ERROR_ACCESS_VIOLATION,
                        '/arithmetic exception, numeric overflow, or string truncation/' => MDB_ERROR_DIVZERO,
                        '/deadlock/' => MDB_ERROR_DEADLOCK,
                        '/attempt to store duplicate value/' => MDB_ERROR_CONSTRAINT
                    );
                }
                foreach ($error_regexps as $regexp => $code) {
                    if (preg_match($regexp, $errormsg)) {
                        return $code;
                    }
                }
        }
        return MDB_ERROR;
    }
function errorCode ( $ errormsg ) { if ( preg_match ( '/^([^0-9\-]+)([0-9\-]+)\s+(.*)$/' , $ errormsg , $ match ) ) { $ errno = ( int ) $ match [ 2 ] ; } else { $ errno = NULL ; } switch ( $ errno ) { case - 204 : if ( is_int ( strpos ( $ match [ 3 ] , 'Table unknown' ) ) ) { return MDB_ERROR_NOSUCHTABLE ; } break ; default : if ( isset ( $ this -> errorcode_map [ $ errno ] ) ) { return ( $ this -> errorcode_map [ $ errno ] ) ; } static $ error_regexps ; if ( empty ( $ error_regexps ) ) { $ error_regexps = array ( '/[tT]able not found/' => MDB_ERROR_NOSUCHTABLE , '/[tT]able unknown/' => MDB_ERROR_NOSUCHTABLE , '/[tT]able .* already exists/' => MDB_ERROR_ALREADY_EXISTS , '/validation error for column .* value "\*\*\* null/' => MDB_ERROR_CONSTRAINT_NOT_NULL , '/violation of [\w ]+ constraint/' => MDB_ERROR_CONSTRAINT , '/conversion error from string/' => MDB_ERROR_INVALID_NUMBER , '/no permission for/' => MDB_ERROR_ACCESS_VIOLATION , '/arithmetic exception, numeric overflow, or string truncation/' => MDB_ERROR_DIVZERO , '/deadlock/' => MDB_ERROR_DEADLOCK , '/attempt to store duplicate value/' => MDB_ERROR_CONSTRAINT ) ; } foreach ( $ error_regexps as $ regexp => $ code ) { if ( preg_match ( $ regexp , $ errormsg ) ) { return $ code ; } } } return MDB_ERROR ; }
Map native error codes to DB's portable ones.
Map native error codes to DB ' s portable ones .
// memo for the interbase php module hackers: we need something similar // to mysql_errno() to retrieve error codes instead of this ugly hack // Fall back to MDB_ERROR if there was no mapping.