]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/WikiDB/adodb/adodb-errorpear.inc.php
new ADODB library 4.22 with multiple drivers (not only mysql as before), major change...
[SourceForge/phpwiki.git] / lib / WikiDB / adodb / adodb-errorpear.inc.php
1 <?php\r
2 /** \r
3  * @version V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.\r
4  * Released under both BSD license and Lesser GPL library license. \r
5   Whenever there is any discrepancy between the two licenses, \r
6   the BSD license will take precedence. \r
7  *\r
8  * Set tabs to 4 for best viewing.\r
9  * \r
10  * Latest version is available at http://php.weblogs.com\r
11  * \r
12 */\r
13 include_once('PEAR.php');\r
14 \r
15 define('ADODB_ERROR_HANDLER','ADODB_Error_PEAR');\r
16 \r
17 /*\r
18 * Enabled the following if you want to terminate scripts when an error occurs\r
19 */\r
20 //PEAR::setErrorHandling (PEAR_ERROR_DIE);\r
21 \r
22 /*\r
23 * Name of the PEAR_Error derived class to call.\r
24 */\r
25 if (!defined('ADODB_PEAR_ERROR_CLASS')) define('ADODB_PEAR_ERROR_CLASS','PEAR_Error');\r
26 \r
27 /*\r
28 * Store the last PEAR_Error object here\r
29 */\r
30 global $ADODB_Last_PEAR_Error; $ADODB_Last_PEAR_Error = false;\r
31 \r
32   /**\r
33 * Error Handler with PEAR support. This will be called with the following params\r
34 *\r
35 * @param $dbms          the RDBMS you are connecting to\r
36 * @param $fn            the name of the calling function (in uppercase)\r
37 * @param $errno         the native error number from the database \r
38 * @param $errmsg        the native error msg from the database\r
39 * @param $p1            $fn specific parameter - see below\r
40 * @param $P2            $fn specific parameter - see below\r
41         */\r
42 function ADODB_Error_PEAR($dbms, $fn, $errno, $errmsg, $p1=false, $p2=false)\r
43 {\r
44 global $ADODB_Last_PEAR_Error;\r
45         \r
46         if (error_reporting() == 0) return; // obey @ protocol\r
47         switch($fn) {\r
48         case 'EXECUTE':\r
49                 $sql = $p1;\r
50                 $inputparams = $p2;\r
51                 \r
52                 $s = "$dbms error: [$errno: $errmsg] in $fn(\"$sql\")";\r
53                 break;\r
54                 \r
55         case 'PCONNECT':\r
56         case 'CONNECT':\r
57                 $host = $p1;\r
58                 $database = $p2;\r
59                 \r
60                 $s = "$dbms error: [$errno: $errmsg] in $fn('$host', ?, ?, '$database')";\r
61                 break;\r
62                 \r
63         default:\r
64                 $s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)";\r
65                 break;\r
66         }\r
67         \r
68         $class = ADODB_PEAR_ERROR_CLASS;\r
69         $ADODB_Last_PEAR_Error = new $class($s, $errno,\r
70                 $GLOBALS['_PEAR_default_error_mode'],\r
71                 $GLOBALS['_PEAR_default_error_options'], \r
72                 $errmsg);\r
73                 \r
74         //print "<p>!$s</p>";\r
75 }\r
76 \r
77 /**\r
78 * Returns last PEAR_Error object. This error might be for an error that\r
79 * occured several sql statements ago.\r
80 */\r
81 function &ADODB_PEAR_Error()\r
82 {\r
83 global $ADODB_Last_PEAR_Error;\r
84 \r
85         return $ADODB_Last_PEAR_Error;\r
86 }\r
87                 \r
88 ?>