2 /** @package verysimple::DB::Reflection */
5 * import supporting libraries
7 require_once('verysimple/DB/DatabaseException.php');
9 define("DBH_LOG_NONE", 1);
10 define("DBH_LOG_INFO", 2);
11 define("DBH_LOG_DEBUG", 4);
12 define("DBH_LOG_QUERY", 8);
13 define("DBH_LOG_WARNING", 16);
14 define("DBH_LOG_ERROR", 32);
17 * DBEventHandler is an optional parameter that can be used to hook into events in the
18 * DAO system for intercepting, debugging and observing
20 * @package verysimple::DB::Reflection
21 * @author Jason Hinkle
22 * @copyright 1997-2007 VerySimple, Inc.
23 * @license http://www.gnu.org/licenses/lgpl.html LGPL
29 function __construct($level = DBH_LOG_NONE
)
31 $this->LogLevel
= $level;
35 * Called by DB objects to report logging information
39 * @param string $message
42 function Log($level, $message, $data = "")
44 $data = $data != "" ?
": $data" : "";
47 if ($this->LogLevel
& DBH_LOG_DEBUG
) {
48 print "<pre style='color: silver;'>$message</pre>\r\n";
52 if ($this->LogLevel
& DBH_LOG_INFO
) {
53 print "<pre style='color: blue;'>$message $data</pre>\r\n";
57 if ($this->LogLevel
& DBH_LOG_QUERY
) {
58 print "<pre style='color: green;'>$message $data</pre>\r\n";
62 if ($this->LogLevel
& DBH_LOG_WARNING
) {
63 print "<pre style='color: orange;'>$message $data</pre>\r\n";
67 if ($this->LogLevel
& DBH_LOG_ERROR
) {
68 print "<pre style='color: red;'>$message $data</pre>\r\n";
75 * Called by DB objects when a critical error occurs
79 * unique numerical identifier for error
80 * @param string $message
81 * human-readable error
83 * any additional information that may help with debugging
85 function Crash($code, $message = "", $data = "")
87 throw new DatabaseException($message, $code, $data);