15 if (!defined(
"DB_ERROR")) define(
"DB_ERROR",-1);
17 if (!defined(
"DB_ERROR_SYNTAX")) {
18 define(
"DB_ERROR_SYNTAX", -2);
19 define(
"DB_ERROR_CONSTRAINT", -3);
20 define(
"DB_ERROR_NOT_FOUND", -4);
21 define(
"DB_ERROR_ALREADY_EXISTS", -5);
22 define(
"DB_ERROR_UNSUPPORTED", -6);
23 define(
"DB_ERROR_MISMATCH", -7);
24 define(
"DB_ERROR_INVALID", -8);
25 define(
"DB_ERROR_NOT_CAPABLE", -9);
26 define(
"DB_ERROR_TRUNCATED", -10);
27 define(
"DB_ERROR_INVALID_NUMBER", -11);
28 define(
"DB_ERROR_INVALID_DATE", -12);
29 define(
"DB_ERROR_DIVZERO", -13);
30 define(
"DB_ERROR_NODBSELECTED", -14);
31 define(
"DB_ERROR_CANNOT_CREATE", -15);
32 define(
"DB_ERROR_CANNOT_DELETE", -16);
33 define(
"DB_ERROR_CANNOT_DROP", -17);
34 define(
"DB_ERROR_NOSUCHTABLE", -18);
35 define(
"DB_ERROR_NOSUCHFIELD", -19);
36 define(
"DB_ERROR_NEED_MORE_DATA", -20);
37 define(
"DB_ERROR_NOT_LOCKED", -21);
38 define(
"DB_ERROR_VALUE_COUNT_ON_ROW", -22);
39 define(
"DB_ERROR_INVALID_DSN", -23);
40 define(
"DB_ERROR_CONNECT_FAILED", -24);
41 define(
"DB_ERROR_EXTENSION_NOT_FOUND",-25);
42 define(
"DB_ERROR_NOSUCHDB", -25);
43 define(
"DB_ERROR_ACCESS_VIOLATION", -26);
44 define(
"DB_ERROR_DEADLOCK", -27);
45 define(
"DB_ERROR_STATEMENT_TIMEOUT", -28);
46 define(
"DB_ERROR_SERIALIZATION_FAILURE", -29);
53 if (empty($ADODB_LANG)) $ADODB_LANG =
'en';
54 if (isset($ADODB_LANG_ARRAY[
'LANG']) && $ADODB_LANG_ARRAY[
'LANG'] == $ADODB_LANG) ;
56 include_once(ADODB_DIR.
"/lang/adodb-$ADODB_LANG.inc.php");
58 return isset($ADODB_LANG_ARRAY[$value]) ? $ADODB_LANG_ARRAY[$value] : $ADODB_LANG_ARRAY[DB_ERROR];
64 if (is_numeric($errno) && $errno == 0)
return 0;
88 if (isset($map[$errno]))
return $map[$errno];
96 if (is_numeric($errormsg))
return (integer) $errormsg;
98 static $error_regexps = array(
99 '(Table does not exist\.|Relation [\"\'].*[\"\'] does not exist|sequence does not exist|class ".+" not found)$' => DB_ERROR_NOSUCHTABLE,
100 'Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*|duplicate key.*violates unique constraint' => DB_ERROR_ALREADY_EXISTS,
101 'database ".+" does not exist$' => DB_ERROR_NOSUCHDB,
102 '(divide|division) by zero$' => DB_ERROR_DIVZERO,
103 'pg_atoi: error in .*: can\'t parse ' => DB_ERROR_INVALID_NUMBER,
104 'ttribute [\"\'].*[\"\'] not found|Relation [\"\'].*[\"\'] does not have attribute [\"\'].*[\"\']' => DB_ERROR_NOSUCHFIELD,
105 '(parser: parse|syntax) error at or near \"' => DB_ERROR_SYNTAX,
106 'referential integrity violation' => DB_ERROR_CONSTRAINT,
107 'deadlock detected$' => DB_ERROR_DEADLOCK,
108 'canceling statement due to statement timeout$' => DB_ERROR_STATEMENT_TIMEOUT,
109 'could not serialize access due to' => DB_ERROR_SERIALIZATION_FAILURE
111 reset($error_regexps);
112 while (list(
$regexp,$code) = each($error_regexps)) {
113 if (preg_match(
"/$regexp/mi", $errormsg)) {
124 '01004' => DB_ERROR_TRUNCATED,
125 '07001' => DB_ERROR_MISMATCH,
126 '21S01' => DB_ERROR_MISMATCH,
127 '21S02' => DB_ERROR_MISMATCH,
128 '22003' => DB_ERROR_INVALID_NUMBER,
129 '22008' => DB_ERROR_INVALID_DATE,
130 '22012' => DB_ERROR_DIVZERO,
131 '23000' => DB_ERROR_CONSTRAINT,
132 '24000' => DB_ERROR_INVALID,
133 '34000' => DB_ERROR_INVALID,
134 '37000' => DB_ERROR_SYNTAX,
135 '42000' => DB_ERROR_SYNTAX,
136 'IM001' => DB_ERROR_UNSUPPORTED,
137 'S0000' => DB_ERROR_NOSUCHTABLE,
138 'S0001' => DB_ERROR_NOT_FOUND,
139 'S0002' => DB_ERROR_NOSUCHTABLE,
140 'S0011' => DB_ERROR_ALREADY_EXISTS,
141 'S0012' => DB_ERROR_NOT_FOUND,
142 'S0021' => DB_ERROR_ALREADY_EXISTS,
143 'S0022' => DB_ERROR_NOT_FOUND,
144 'S1000' => DB_ERROR_NOSUCHTABLE,
145 'S1009' => DB_ERROR_INVALID,
146 'S1090' => DB_ERROR_INVALID,
147 'S1C00' => DB_ERROR_NOT_CAPABLE
155 -104 => DB_ERROR_SYNTAX,
156 -150 => DB_ERROR_ACCESS_VIOLATION,
157 -151 => DB_ERROR_ACCESS_VIOLATION,
158 -155 => DB_ERROR_NOSUCHTABLE,
159 -157 => DB_ERROR_NOSUCHFIELD,
160 -158 => DB_ERROR_VALUE_COUNT_ON_ROW,
161 -170 => DB_ERROR_MISMATCH,
162 -171 => DB_ERROR_MISMATCH,
163 -172 => DB_ERROR_INVALID,
164 -204 => DB_ERROR_INVALID,
165 -205 => DB_ERROR_NOSUCHFIELD,
166 -206 => DB_ERROR_NOSUCHFIELD,
167 -208 => DB_ERROR_INVALID,
168 -219 => DB_ERROR_NOSUCHTABLE,
169 -297 => DB_ERROR_CONSTRAINT,
170 -530 => DB_ERROR_CONSTRAINT,
171 -803 => DB_ERROR_CONSTRAINT,
172 -551 => DB_ERROR_ACCESS_VIOLATION,
173 -552 => DB_ERROR_ACCESS_VIOLATION,
174 -922 => DB_ERROR_NOSUCHDB,
175 -923 => DB_ERROR_CONNECT_FAILED,
176 -924 => DB_ERROR_CONNECT_FAILED
185 '-201' => DB_ERROR_SYNTAX,
186 '-206' => DB_ERROR_NOSUCHTABLE,
187 '-217' => DB_ERROR_NOSUCHFIELD,
188 '-329' => DB_ERROR_NODBSELECTED,
189 '-1204' => DB_ERROR_INVALID_DATE,
190 '-1205' => DB_ERROR_INVALID_DATE,
191 '-1206' => DB_ERROR_INVALID_DATE,
192 '-1209' => DB_ERROR_INVALID_DATE,
193 '-1210' => DB_ERROR_INVALID_DATE,
194 '-1212' => DB_ERROR_INVALID_DATE
203 1 => DB_ERROR_ALREADY_EXISTS,
204 900 => DB_ERROR_SYNTAX,
205 904 => DB_ERROR_NOSUCHFIELD,
206 923 => DB_ERROR_SYNTAX,
207 942 => DB_ERROR_NOSUCHTABLE,
208 955 => DB_ERROR_ALREADY_EXISTS,
209 1476 => DB_ERROR_DIVZERO,
210 1722 => DB_ERROR_INVALID_NUMBER,
211 2289 => DB_ERROR_NOSUCHTABLE,
212 2291 => DB_ERROR_CONSTRAINT,
213 2449 => DB_ERROR_CONSTRAINT
222 208 => DB_ERROR_NOSUCHTABLE,
223 2601 => DB_ERROR_ALREADY_EXISTS
241 1004 => DB_ERROR_CANNOT_CREATE,
242 1005 => DB_ERROR_CANNOT_CREATE,
243 1006 => DB_ERROR_CANNOT_CREATE,
244 1007 => DB_ERROR_ALREADY_EXISTS,
245 1008 => DB_ERROR_CANNOT_DROP,
246 1045 => DB_ERROR_ACCESS_VIOLATION,
247 1046 => DB_ERROR_NODBSELECTED,
248 1049 => DB_ERROR_NOSUCHDB,
249 1050 => DB_ERROR_ALREADY_EXISTS,
250 1051 => DB_ERROR_NOSUCHTABLE,
251 1054 => DB_ERROR_NOSUCHFIELD,
252 1062 => DB_ERROR_ALREADY_EXISTS,
253 1064 => DB_ERROR_SYNTAX,
254 1100 => DB_ERROR_NOT_LOCKED,
255 1136 => DB_ERROR_VALUE_COUNT_ON_ROW,
256 1146 => DB_ERROR_NOSUCHTABLE,
257 1048 => DB_ERROR_CONSTRAINT,
258 2002 => DB_ERROR_CONNECT_FAILED,
259 2005 => DB_ERROR_CONNECT_FAILED
adodb_error_pg($errormsg)
if(!defined('SINGLEQUOTE')) define('SINGLEQUOTE' drivers adodb mssql inc php t an odd number of single quotes(this can cause problems below *and should be considered one wrong SQL). Exit with debug info. */if((substr_count($sql SINGLEQUOTE $regexp)
adodb_error($provider, $dbType, $errno)
if(!defined("DB_ERROR_SYNTAX")) adodb_errormsg($value)