Revert "Firebird exceptions"

This reverts commit e89a2cedba.
This commit is contained in:
Timothy Warren 2012-03-07 15:21:44 -05:00
parent e89a2cedba
commit 7568afefa6
2 changed files with 16 additions and 28 deletions

View File

@ -19,7 +19,7 @@
*/ */
class firebird extends DB_PDO { class firebird extends DB_PDO {
protected $statement, $trans, $count, $result, $conn; protected $statement, $trans, $count, $result;
/** /**
* Open the link to the database * Open the link to the database
@ -34,12 +34,13 @@ class firebird extends DB_PDO {
// pass around the resource that this provides. // pass around the resource that this provides.
// Since the resource is not required by the // Since the resource is not required by the
// functions that would use it, I'm dumping it. // 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 // 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"; $class = __CLASS__."_sql";
@ -95,9 +96,10 @@ class firebird extends DB_PDO {
// Throw the error as a exception // Throw the error as a exception
// if there is one // 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; return $this->statement;
@ -116,24 +118,17 @@ class firebird extends DB_PDO {
switch($fetch_style) switch($fetch_style)
{ {
case PDO::FETCH_OBJ: case PDO::FETCH_OBJ:
$row = @ibase_fetch_object($this->statement, IBASE_FETCH_BLOBS); return ibase_fetch_object($this->statement, IBASE_FETCH_BLOBS);
break; break;
case PDO::FETCH_NUM: case PDO::FETCH_NUM:
$row = @ibase_fetch_row($this->statement, IBASE_FETCH_BLOBS); return ibase_fetch_row($this->statement, IBASE_FETCH_BLOBS);
break; break;
default: default:
$row = @ibase_fetch_assoc($this->statement, IBASE_FETCH_BLOBS); return ibase_fetch_assoc($this->statement, IBASE_FETCH_BLOBS);
break; 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 // Throw the error as an exception
if ($this->statement === FALSE) if ($this->statement === FALSE)
{ {
throw new PDOException(ibase_errcode() . "\n" . ibase_errmsg()); throw new PDOException(ibase_errmsg());
die();
} }
return $this->statement; return $this->statement;
@ -275,7 +271,7 @@ SQL;
*/ */
public function beginTransaction() public function beginTransaction()
{ {
if(($this->trans = ibase_trans($this->conn, IBASE_DEFAULT)) !== FALSE) if(($this->trans = ibase_trans()) !== NULL)
{ {
return TRUE; return TRUE;
} }

View File

@ -33,21 +33,13 @@ class FirebirdTest extends UnitTestCase {
function setUp() function setUp()
{ {
$dbpath = TEST_DIR.DS.'test_dbs'.DS.'FB_TEST_DB.FDB'; $dbpath = TEST_DIR.DS.'test_dbs'.DS.'FB_TEST_DB.FDB';
$this->db = new Firebird($dbpath);
try
{
$this->db = new Firebird('localhost:'.$dbpath, 'sysdba', 'masterkey');
}
catch(PDOException $e)
{
die('Firebird connection fail: '.$e->getMessage());
}
$this->tables = $this->db->get_tables(); $this->tables = $this->db->get_tables();
} }
function tearDown() function tearDown()
{ {
unset($this->db);
unset($this->tables); unset($this->tables);
} }