From 9b3a242b048107fa6b33f438673489a12d4bc352 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Tue, 10 Apr 2012 09:38:57 -0400 Subject: [PATCH] Convert all errors to execeptions --- index.php | 12 +++++++++++- sys/db/drivers/firebird/firebird_driver.php | 12 ++++++------ sys/db/drivers/firebird/firebird_sql.php | 2 +- tests/test_dbs/FB_TEST_DB.FDB | Bin 802816 -> 802816 bytes 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/index.php b/index.php index 9398db4..306eb07 100644 --- a/index.php +++ b/index.php @@ -26,7 +26,7 @@ error_reporting(-1 & ~(E_STRICT)); // Set the stupid timezone so PHP shuts up. date_default_timezone_set('GMT'); -// Don't set an arbitary memory limit! +// Don't set an arbitrary memory limit! ini_set('memory_limit', -1); // Set the current directory as the base for included files @@ -75,6 +75,16 @@ if( ! class_exists('pdo')) // -------------------------------------------------------------------------- +// Convert Errors to Exceptions +// Do this after the two compatibility checks for cleaner output +function exception_error_handler($errno, $errstr, $errfile, $errline) +{ + throw new ErrorException($errstr, 0, $errno, $errfile, $errline); +} +set_error_handler("exception_error_handler", -1); + +// -------------------------------------------------------------------------- + /** * Alias for require_once for array_map * diff --git a/sys/db/drivers/firebird/firebird_driver.php b/sys/db/drivers/firebird/firebird_driver.php index 7a61546..c5ca01d 100644 --- a/sys/db/drivers/firebird/firebird_driver.php +++ b/sys/db/drivers/firebird/firebird_driver.php @@ -30,14 +30,14 @@ class firebird extends DB_PDO { */ public function __construct($dbpath, $user='sysdba', $pass='masterkey') { - $this->conn = @fbird_connect($dbpath, $user, $pass, 'utf-8'); + $this->conn = fbird_connect($dbpath, $user, $pass, 'utf-8'); // Throw an exception to make this match other pdo classes - if ( ! is_resource($this->conn)) + /*if ( ! is_resource($this->conn)) { throw new PDOException(fbird_errmsg()); die(); - } + }*/ $class = __CLASS__."_sql"; $this->sql = new $class; @@ -91,8 +91,8 @@ class firebird extends DB_PDO { $this->count = 0; $this->statement_link = (isset($this->trans)) - ? @fbird_query($this->trans, $sql) - : @fbird_query($this->conn, $sql); + ? fbird_query($this->trans, $sql) + : fbird_query($this->conn, $sql); // Throw the error as a exception if ($this->statement_link === FALSE) @@ -115,7 +115,7 @@ class firebird extends DB_PDO { */ public function prepare($query, $options=NULL) { - $this->statement_link = @fbird_prepare($this->conn, $query); + $this->statement_link = fbird_prepare($this->conn, $query); // Throw the error as an exception if ($this->statement_link === FALSE) diff --git a/sys/db/drivers/firebird/firebird_sql.php b/sys/db/drivers/firebird/firebird_sql.php index bea8a03..c7e6feb 100644 --- a/sys/db/drivers/firebird/firebird_sql.php +++ b/sys/db/drivers/firebird/firebird_sql.php @@ -136,7 +136,7 @@ class Firebird_SQL extends DB_SQL { */ public function backup_structure() { - // @todo Implement Backup function + // @todo Implement Backup structure function return ''; } diff --git a/tests/test_dbs/FB_TEST_DB.FDB b/tests/test_dbs/FB_TEST_DB.FDB index af187fb7d7c2653ee68eb8365ad6c6b16b0ffa97..d78e6c1e74984c9c6a2105c876a75bdeef998794 100755 GIT binary patch delta 557 zcmZ9I&o2W(6vyApZqa>yj2|abwu*{Gv_TLD1Q+7a5FAP*LO4~@i{o;bxDZ0TgMmc3XY6VGCbSGtMMy%7d1ne0qZw17e8r^y1gvjlAvaG0-}G@nJ2j3;bk zD^zJ?6W!-9%$8`*#(Fw_!YbOfu{yf=t>fV6pc@ps#MtY*V)*K_8M?JGNFR^b#-~lX z%43Kwvl!-+Cha_9$Cows&#G8i6)WqgYaQn!o^Xs0nN*&~z@L}{|AdN_P_Ytr{>CI> Xqd|9htn-3W+{MFZ3}>7VNX~u&yn}%A delta 545 zcmZ9JO(;ZB6vxkbGxHvE(i{sZG9ShmP04#9#ts{j#pE*|WhcdIRua9GyA-9)!phQ) zjoB$>i#1X+Mp>9*W$nF}i`>&a_x^6TU;o>6UB`8uNrb$;or2%Nq%D91SxL zl_JS#TOG#E3s07^qZc-X&(g(kVEbva7z5kP1e`P*VBYLJEHpK{RuY!1b{MqMz*ZO3 z%rsn^nbK65P7V2}5aX8MGsWfcoifg50^rhf7=VCr0L>nG<@9NWfcs%Xutpi#uTUqh z%hfY=$bE&fxaK=Yoz;Ij&042f>lS@oN_NVW!vz_BqY0e*lWyjpPP5i&*1GXO>BfH2 zH8=X-