Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]
1 <?php 2 /** 3 * @version v5.20.16 12-Jan-2020 4 * @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved. 5 * @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community 6 * Released under both BSD license and Lesser GPL library license. 7 * Whenever there is any discrepancy between the two licenses, 8 * the BSD license will take precedence. 9 * 10 * Set tabs to 4 for best viewing. 11 * 12 * The following code is adapted from the PEAR DB error handling code. 13 * Portions (c)1997-2002 The PHP Group. 14 */ 15 16 17 if (!defined("DB_ERROR")) define("DB_ERROR",-1); 18 19 if (!defined("DB_ERROR_SYNTAX")) { 20 define("DB_ERROR_SYNTAX", -2); 21 define("DB_ERROR_CONSTRAINT", -3); 22 define("DB_ERROR_NOT_FOUND", -4); 23 define("DB_ERROR_ALREADY_EXISTS", -5); 24 define("DB_ERROR_UNSUPPORTED", -6); 25 define("DB_ERROR_MISMATCH", -7); 26 define("DB_ERROR_INVALID", -8); 27 define("DB_ERROR_NOT_CAPABLE", -9); 28 define("DB_ERROR_TRUNCATED", -10); 29 define("DB_ERROR_INVALID_NUMBER", -11); 30 define("DB_ERROR_INVALID_DATE", -12); 31 define("DB_ERROR_DIVZERO", -13); 32 define("DB_ERROR_NODBSELECTED", -14); 33 define("DB_ERROR_CANNOT_CREATE", -15); 34 define("DB_ERROR_CANNOT_DELETE", -16); 35 define("DB_ERROR_CANNOT_DROP", -17); 36 define("DB_ERROR_NOSUCHTABLE", -18); 37 define("DB_ERROR_NOSUCHFIELD", -19); 38 define("DB_ERROR_NEED_MORE_DATA", -20); 39 define("DB_ERROR_NOT_LOCKED", -21); 40 define("DB_ERROR_VALUE_COUNT_ON_ROW", -22); 41 define("DB_ERROR_INVALID_DSN", -23); 42 define("DB_ERROR_CONNECT_FAILED", -24); 43 define("DB_ERROR_EXTENSION_NOT_FOUND",-25); 44 define("DB_ERROR_NOSUCHDB", -25); 45 define("DB_ERROR_ACCESS_VIOLATION", -26); 46 define("DB_ERROR_DEADLOCK", -27); 47 define("DB_ERROR_STATEMENT_TIMEOUT", -28); 48 define("DB_ERROR_SERIALIZATION_FAILURE", -29); 49 } 50 51 function adodb_errormsg($value) 52 { 53 global $ADODB_LANG,$ADODB_LANG_ARRAY; 54 55 if (empty($ADODB_LANG)) $ADODB_LANG = 'en'; 56 if (isset($ADODB_LANG_ARRAY['LANG']) && $ADODB_LANG_ARRAY['LANG'] == $ADODB_LANG) ; 57 else { 58 include_once(ADODB_DIR."/lang/adodb-$ADODB_LANG.inc.php"); 59 } 60 return isset($ADODB_LANG_ARRAY[$value]) ? $ADODB_LANG_ARRAY[$value] : $ADODB_LANG_ARRAY[DB_ERROR]; 61 } 62 63 function adodb_error($provider,$dbType,$errno) 64 { 65 //var_dump($errno); 66 if (is_numeric($errno) && $errno == 0) return 0; 67 switch($provider) { 68 case 'mysql': $map = adodb_error_mysql(); break; 69 70 case 'oracle': 71 case 'oci8': $map = adodb_error_oci8(); break; 72 73 case 'ibase': $map = adodb_error_ibase(); break; 74 75 case 'odbc': $map = adodb_error_odbc(); break; 76 77 case 'mssql': 78 case 'sybase': $map = adodb_error_mssql(); break; 79 80 case 'informix': $map = adodb_error_ifx(); break; 81 82 case 'postgres': return adodb_error_pg($errno); break; 83 84 case 'sqlite': return $map = adodb_error_sqlite(); break; 85 default: 86 return DB_ERROR; 87 } 88 //print_r($map); 89 //var_dump($errno); 90 if (isset($map[$errno])) return $map[$errno]; 91 return DB_ERROR; 92 } 93 94 //************************************************************************************** 95 96 function adodb_error_pg($errormsg) 97 { 98 if (is_numeric($errormsg)) return (integer) $errormsg; 99 // Postgres has no lock-wait timeout. The best we could do would be to set a statement timeout. 100 static $error_regexps = array( 101 '(Table does not exist\.|Relation [\"\'].*[\"\'] does not exist|sequence does not exist|class ".+" not found)$' => DB_ERROR_NOSUCHTABLE, 102 'Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*|duplicate key.*violates unique constraint' => DB_ERROR_ALREADY_EXISTS, 103 'database ".+" does not exist$' => DB_ERROR_NOSUCHDB, 104 '(divide|division) by zero$' => DB_ERROR_DIVZERO, 105 'pg_atoi: error in .*: can\'t parse ' => DB_ERROR_INVALID_NUMBER, 106 'ttribute [\"\'].*[\"\'] not found|Relation [\"\'].*[\"\'] does not have attribute [\"\'].*[\"\']' => DB_ERROR_NOSUCHFIELD, 107 '(parser: parse|syntax) error at or near \"' => DB_ERROR_SYNTAX, 108 'referential integrity violation' => DB_ERROR_CONSTRAINT, 109 'deadlock detected$' => DB_ERROR_DEADLOCK, 110 'canceling statement due to statement timeout$' => DB_ERROR_STATEMENT_TIMEOUT, 111 'could not serialize access due to' => DB_ERROR_SERIALIZATION_FAILURE 112 ); 113 reset($error_regexps); 114 foreach ($error_regexps as $regexp => $code) { 115 if (preg_match("/$regexp/mi", $errormsg)) { 116 return $code; 117 } 118 } 119 // Fall back to DB_ERROR if there was no mapping. 120 return DB_ERROR; 121 } 122 123 function adodb_error_odbc() 124 { 125 static $MAP = array( 126 '01004' => DB_ERROR_TRUNCATED, 127 '07001' => DB_ERROR_MISMATCH, 128 '21S01' => DB_ERROR_MISMATCH, 129 '21S02' => DB_ERROR_MISMATCH, 130 '22003' => DB_ERROR_INVALID_NUMBER, 131 '22008' => DB_ERROR_INVALID_DATE, 132 '22012' => DB_ERROR_DIVZERO, 133 '23000' => DB_ERROR_CONSTRAINT, 134 '24000' => DB_ERROR_INVALID, 135 '34000' => DB_ERROR_INVALID, 136 '37000' => DB_ERROR_SYNTAX, 137 '42000' => DB_ERROR_SYNTAX, 138 'IM001' => DB_ERROR_UNSUPPORTED, 139 'S0000' => DB_ERROR_NOSUCHTABLE, 140 'S0001' => DB_ERROR_NOT_FOUND, 141 'S0002' => DB_ERROR_NOSUCHTABLE, 142 'S0011' => DB_ERROR_ALREADY_EXISTS, 143 'S0012' => DB_ERROR_NOT_FOUND, 144 'S0021' => DB_ERROR_ALREADY_EXISTS, 145 'S0022' => DB_ERROR_NOT_FOUND, 146 'S1000' => DB_ERROR_NOSUCHTABLE, 147 'S1009' => DB_ERROR_INVALID, 148 'S1090' => DB_ERROR_INVALID, 149 'S1C00' => DB_ERROR_NOT_CAPABLE 150 ); 151 return $MAP; 152 } 153 154 function adodb_error_ibase() 155 { 156 static $MAP = array( 157 -104 => DB_ERROR_SYNTAX, 158 -150 => DB_ERROR_ACCESS_VIOLATION, 159 -151 => DB_ERROR_ACCESS_VIOLATION, 160 -155 => DB_ERROR_NOSUCHTABLE, 161 -157 => DB_ERROR_NOSUCHFIELD, 162 -158 => DB_ERROR_VALUE_COUNT_ON_ROW, 163 -170 => DB_ERROR_MISMATCH, 164 -171 => DB_ERROR_MISMATCH, 165 -172 => DB_ERROR_INVALID, 166 -204 => DB_ERROR_INVALID, 167 -205 => DB_ERROR_NOSUCHFIELD, 168 -206 => DB_ERROR_NOSUCHFIELD, 169 -208 => DB_ERROR_INVALID, 170 -219 => DB_ERROR_NOSUCHTABLE, 171 -297 => DB_ERROR_CONSTRAINT, 172 -530 => DB_ERROR_CONSTRAINT, 173 -803 => DB_ERROR_CONSTRAINT, 174 -551 => DB_ERROR_ACCESS_VIOLATION, 175 -552 => DB_ERROR_ACCESS_VIOLATION, 176 -922 => DB_ERROR_NOSUCHDB, 177 -923 => DB_ERROR_CONNECT_FAILED, 178 -924 => DB_ERROR_CONNECT_FAILED 179 ); 180 181 return $MAP; 182 } 183 184 function adodb_error_ifx() 185 { 186 static $MAP = array( 187 '-201' => DB_ERROR_SYNTAX, 188 '-206' => DB_ERROR_NOSUCHTABLE, 189 '-217' => DB_ERROR_NOSUCHFIELD, 190 '-329' => DB_ERROR_NODBSELECTED, 191 '-1204' => DB_ERROR_INVALID_DATE, 192 '-1205' => DB_ERROR_INVALID_DATE, 193 '-1206' => DB_ERROR_INVALID_DATE, 194 '-1209' => DB_ERROR_INVALID_DATE, 195 '-1210' => DB_ERROR_INVALID_DATE, 196 '-1212' => DB_ERROR_INVALID_DATE 197 ); 198 199 return $MAP; 200 } 201 202 function adodb_error_oci8() 203 { 204 static $MAP = array( 205 1 => DB_ERROR_ALREADY_EXISTS, 206 900 => DB_ERROR_SYNTAX, 207 904 => DB_ERROR_NOSUCHFIELD, 208 923 => DB_ERROR_SYNTAX, 209 942 => DB_ERROR_NOSUCHTABLE, 210 955 => DB_ERROR_ALREADY_EXISTS, 211 1476 => DB_ERROR_DIVZERO, 212 1722 => DB_ERROR_INVALID_NUMBER, 213 2289 => DB_ERROR_NOSUCHTABLE, 214 2291 => DB_ERROR_CONSTRAINT, 215 2449 => DB_ERROR_CONSTRAINT 216 ); 217 218 return $MAP; 219 } 220 221 function adodb_error_mssql() 222 { 223 static $MAP = array( 224 208 => DB_ERROR_NOSUCHTABLE, 225 2601 => DB_ERROR_ALREADY_EXISTS 226 ); 227 228 return $MAP; 229 } 230 231 function adodb_error_sqlite() 232 { 233 static $MAP = array( 234 1 => DB_ERROR_SYNTAX 235 ); 236 237 return $MAP; 238 } 239 240 function adodb_error_mysql() 241 { 242 static $MAP = array( 243 1004 => DB_ERROR_CANNOT_CREATE, 244 1005 => DB_ERROR_CANNOT_CREATE, 245 1006 => DB_ERROR_CANNOT_CREATE, 246 1007 => DB_ERROR_ALREADY_EXISTS, 247 1008 => DB_ERROR_CANNOT_DROP, 248 1045 => DB_ERROR_ACCESS_VIOLATION, 249 1046 => DB_ERROR_NODBSELECTED, 250 1049 => DB_ERROR_NOSUCHDB, 251 1050 => DB_ERROR_ALREADY_EXISTS, 252 1051 => DB_ERROR_NOSUCHTABLE, 253 1054 => DB_ERROR_NOSUCHFIELD, 254 1062 => DB_ERROR_ALREADY_EXISTS, 255 1064 => DB_ERROR_SYNTAX, 256 1100 => DB_ERROR_NOT_LOCKED, 257 1136 => DB_ERROR_VALUE_COUNT_ON_ROW, 258 1146 => DB_ERROR_NOSUCHTABLE, 259 1048 => DB_ERROR_CONSTRAINT, 260 2002 => DB_ERROR_CONNECT_FAILED, 261 2005 => DB_ERROR_CONNECT_FAILED 262 ); 263 264 return $MAP; 265 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body