irm-1.6-b3/MDB/pgsql.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)
    {
        static $error_regexps;
        if (empty($error_regexps)) {
            $error_regexps = array(
                '/([Tt]able does not exist\.|[Rr]elation [\"\'].*[\"\'] does not exist|[Ss]equence does not exist|[Cc]lass ".+" not found)$/' => MDB_ERROR_NOSUCHTABLE,
                '/[Tt]able [\"\'].*[\"\'] does not exist/' => MDB_ERROR_NOSUCHTABLE,
                '/[Rr]elation [\"\'].*[\"\'] already exists|[Cc]annot insert a duplicate key into (a )?unique index.*/' => MDB_ERROR_ALREADY_EXISTS,
                '/divide by zero$/'                     => MDB_ERROR_DIVZERO,
                '/pg_atoi: error in .*: can\'t parse /' => MDB_ERROR_INVALID_NUMBER,
                '/ttribute [\"\'].*[\"\'] not found$|[Rr]elation [\"\'].*[\"\'] does not have attribute [\"\'].*[\"\']/' => MDB_ERROR_NOSUCHFIELD,
                '/parser: parse error at or near \"/'   => MDB_ERROR_SYNTAX,
                '/syntax error at/'                     => MDB_ERROR_SYNTAX,
                '/violates not-null constraint/'        => MDB_ERROR_CONSTRAINT_NOT_NULL,
                '/violates [\w ]+ constraint/'          => MDB_ERROR_CONSTRAINT,
                '/referential integrity violation/'     => MDB_ERROR_CONSTRAINT,
                '/deadlock detected/'                   => MDB_ERROR_DEADLOCK
            );
        }
        foreach ($error_regexps as $regexp => $code) {
            if (preg_match($regexp, $errormsg)) {
                return($code);
            }
        }
        return(MDB_ERROR);
    }
function errorCode ( $ errormsg ) { static $ error_regexps ; if ( empty ( $ error_regexps ) ) { $ error_regexps = array ( '/([Tt]able does not exist\.|[Rr]elation [\"\'].*[\"\'] does not exist|[Ss]equence does not exist|[Cc]lass ".+" not found)$/' => MDB_ERROR_NOSUCHTABLE , '/[Tt]able [\"\'].*[\"\'] does not exist/' => MDB_ERROR_NOSUCHTABLE , '/[Rr]elation [\"\'].*[\"\'] already exists|[Cc]annot insert a duplicate key into (a )?unique index.*/' => MDB_ERROR_ALREADY_EXISTS , '/divide by zero$/' => MDB_ERROR_DIVZERO , '/pg_atoi: error in .*: can\'t parse /' => MDB_ERROR_INVALID_NUMBER , '/ttribute [\"\'].*[\"\'] not found$|[Rr]elation [\"\'].*[\"\'] does not have attribute [\"\'].*[\"\']/' => MDB_ERROR_NOSUCHFIELD , '/parser: parse error at or near \"/' => MDB_ERROR_SYNTAX , '/syntax error at/' => MDB_ERROR_SYNTAX , '/violates not-null constraint/' => MDB_ERROR_CONSTRAINT_NOT_NULL , '/violates [\w ]+ constraint/' => MDB_ERROR_CONSTRAINT , '/referential integrity violation/' => MDB_ERROR_CONSTRAINT , '/deadlock detected/' => MDB_ERROR_DEADLOCK ) ; } 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 .
// Fall back to MDB_ERROR if there was no mapping.