diff --git a/htdocs/lib/mysql.lib.php b/htdocs/lib/mysql.lib.php index 4be728479ac..a55c4359f21 100644 --- a/htdocs/lib/mysql.lib.php +++ b/htdocs/lib/mysql.lib.php @@ -52,21 +52,22 @@ class DoliDb // Constantes pour conversion code erreur MySql en code erreur générique var $errorcode_map = array( - 1004 => DB_ERROR_CANNOT_CREATE, - 1005 => DB_ERROR_CANNOT_CREATE, - 1006 => DB_ERROR_CANNOT_CREATE, - 1007 => DB_ERROR_ALREADY_EXISTS, - 1008 => DB_ERROR_CANNOT_DROP, - 1046 => DB_ERROR_NODBSELECTED, - 1050 => DB_ERROR_TABLE_ALREADY_EXISTS, - 1051 => DB_ERROR_NOSUCHTABLE, - 1054 => DB_ERROR_NOSUCHFIELD, - 1062 => DB_ERROR_RECORD_ALREADY_EXISTS, - 1064 => DB_ERROR_SYNTAX, - 1100 => DB_ERROR_NOT_LOCKED, - 1136 => DB_ERROR_VALUE_COUNT_ON_ROW, - 1146 => DB_ERROR_NOSUCHTABLE, - 1048 => DB_ERROR_CONSTRAINT, + 1004 => 'DB_ERROR_CANNOT_CREATE', + 1005 => 'DB_ERROR_CANNOT_CREATE', + 1006 => 'DB_ERROR_CANNOT_CREATE', + 1007 => 'DB_ERROR_ALREADY_EXISTS', + 1008 => 'DB_ERROR_CANNOT_DROP', + 1046 => 'DB_ERROR_NODBSELECTED', + 1050 => 'DB_ERROR_TABLE_ALREADY_EXISTS', + 1051 => 'DB_ERROR_NOSUCHTABLE', + 1054 => 'DB_ERROR_NOSUCHFIELD', + 1062 => 'DB_ERROR_RECORD_ALREADY_EXISTS', + 1064 => 'DB_ERROR_SYNTAX', + 1100 => 'DB_ERROR_NOT_LOCKED', + 1136 => 'DB_ERROR_VALUE_COUNT_ON_ROW', + 1146 => 'DB_ERROR_NOSUCHTABLE', + 1048 => 'DB_ERROR_CONSTRAINT', + 1217 => 'DB_ERROR_CHILD_EXISTS' ); /** @@ -473,7 +474,7 @@ class DoliDb if (isset($this->errorcode_map[mysql_errno($this->db)])) { return $this->errorcode_map[mysql_errno($this->db)]; } - return DB_ERROR; + return 'DB_ERROR_'.mysql_errno($this->db); } /** diff --git a/htdocs/lib/pgsql.lib.php b/htdocs/lib/pgsql.lib.php index a1f9094d5a7..4a2cdd31ad6 100644 --- a/htdocs/lib/pgsql.lib.php +++ b/htdocs/lib/pgsql.lib.php @@ -467,14 +467,14 @@ class DoliDb static $error_regexps; if (empty($error_regexps)) { $error_regexps = array( - '/(Table does not exist\.|Relation [\"\'].*[\"\'] does not exist|sequence does not exist|class ".+" not found)$/' => DB_ERROR_NOSUCHTABLE, - '/table [\"\'].*[\"\'] does not exist/' => DB_ERROR_NOSUCHTABLE, - '/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*/' => DB_ERROR_RECORD_ALREADY_EXISTS, - '/divide by zero$/' => DB_ERROR_DIVZERO, - '/pg_atoi: error in .*: can\'t parse /' => DB_ERROR_INVALID_NUMBER, - '/ttribute [\"\'].*[\"\'] not found$|Relation [\"\'].*[\"\'] does not have attribute [\"\'].*[\"\']/' => DB_ERROR_NOSUCHFIELD, - '/parser: parse error at or near \"/' => DB_ERROR_SYNTAX, - '/referential integrity violation/' => DB_ERROR_CONSTRAINT + '/(Table does not exist\.|Relation [\"\'].*[\"\'] does not exist|sequence does not exist|class ".+" not found)$/' => 'DB_ERROR_NOSUCHTABLE', + '/table [\"\'].*[\"\'] does not exist/' => 'DB_ERROR_NOSUCHTABLE', + '/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*/' => 'DB_ERROR_RECORD_ALREADY_EXISTS', + '/divide by zero$/' => 'DB_ERROR_DIVZERO', + '/pg_atoi: error in .*: can\'t parse /' => 'DB_ERROR_INVALID_NUMBER', + '/ttribute [\"\'].*[\"\'] not found$|Relation [\"\'].*[\"\'] does not have attribute [\"\'].*[\"\']/' => 'DB_ERROR_NOSUCHFIELD', + '/parser: parse error at or near \"/' => 'DB_ERROR_SYNTAX', + '/referential integrity violation/' => 'DB_ERROR_CONSTRAINT' ); } foreach ($error_regexps as $regexp => $code) {