From 7568afefa69c7a39c07feb7a62a98d7899cbc0dd Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Wed, 7 Mar 2012 15:21:44 -0500 Subject: [PATCH] Revert "Firebird exceptions" This reverts commit e89a2cedbaff697ae51b00508a0614ed085fe16f. --- sys/databases/firebird-ibase.php | 32 ++++++++++++++------------------ tests/databases/firebird.php | 12 ++---------- 2 files changed, 16 insertions(+), 28 deletions(-) diff --git a/sys/databases/firebird-ibase.php b/sys/databases/firebird-ibase.php index ed3f183..cbd5135 100644 --- a/sys/databases/firebird-ibase.php +++ b/sys/databases/firebird-ibase.php @@ -19,7 +19,7 @@ */ class firebird extends DB_PDO { - protected $statement, $trans, $count, $result, $conn; + protected $statement, $trans, $count, $result; /** * Open the link to the database @@ -34,12 +34,13 @@ class firebird extends DB_PDO { // pass around the resource that this provides. // Since the resource is not required by the // functions that would use it, I'm dumping it. - $this->conn = ibase_connect($dbpath, $user, $pass, 'utf-8'); + $conn = @ibase_connect($dbpath, $user, $pass, 'utf-8'); // Throw an exception to make this match other pdo classes - if ( ! is_resource($this->conn)) + if ( ! is_resource($conn)) { - throw new PDOException(ibase_errcode() . "\n" . ibase_errmsg()); + throw new PDOException(ibase_errmsg()); + die(); } $class = __CLASS__."_sql"; @@ -95,9 +96,10 @@ class firebird extends DB_PDO { // Throw the error as a exception // if there is one - if (ibase_errmsg() !== FALSE) + if ($this->statement === FALSE) { - throw new PDOException(ibase_errcode() . "\n" . ibase_errmsg()); + throw new PDOException(ibase_errmsg()); + die(); } return $this->statement; @@ -116,24 +118,17 @@ class firebird extends DB_PDO { switch($fetch_style) { case PDO::FETCH_OBJ: - $row = @ibase_fetch_object($this->statement, IBASE_FETCH_BLOBS); + return ibase_fetch_object($this->statement, IBASE_FETCH_BLOBS); break; case PDO::FETCH_NUM: - $row = @ibase_fetch_row($this->statement, IBASE_FETCH_BLOBS); + return ibase_fetch_row($this->statement, IBASE_FETCH_BLOBS); break; default: - $row = @ibase_fetch_assoc($this->statement, IBASE_FETCH_BLOBS); + return ibase_fetch_assoc($this->statement, IBASE_FETCH_BLOBS); break; } - - if (ibase_errmsg() !== FALSE) - { - throw new PDOException(ibase_errcode() . "\n" . ibase_errmsg()); - } - - return $row; } // -------------------------------------------------------------------------- @@ -173,7 +168,8 @@ class firebird extends DB_PDO { // Throw the error as an exception if ($this->statement === FALSE) { - throw new PDOException(ibase_errcode() . "\n" . ibase_errmsg()); + throw new PDOException(ibase_errmsg()); + die(); } return $this->statement; @@ -275,7 +271,7 @@ SQL; */ public function beginTransaction() { - if(($this->trans = ibase_trans($this->conn, IBASE_DEFAULT)) !== FALSE) + if(($this->trans = ibase_trans()) !== NULL) { return TRUE; } diff --git a/tests/databases/firebird.php b/tests/databases/firebird.php index cc530c8..2d24587 100644 --- a/tests/databases/firebird.php +++ b/tests/databases/firebird.php @@ -33,21 +33,13 @@ class FirebirdTest extends UnitTestCase { function setUp() { $dbpath = TEST_DIR.DS.'test_dbs'.DS.'FB_TEST_DB.FDB'; - - try - { - $this->db = new Firebird('localhost:'.$dbpath, 'sysdba', 'masterkey'); - } - catch(PDOException $e) - { - die('Firebird connection fail: '.$e->getMessage()); - } - + $this->db = new Firebird($dbpath); $this->tables = $this->db->get_tables(); } function tearDown() { + unset($this->db); unset($this->tables); }