diff --git a/sys/common/db_pdo.php b/sys/common/db_pdo.php index 011b7b3..70a69c2 100644 --- a/sys/common/db_pdo.php +++ b/sys/common/db_pdo.php @@ -105,7 +105,7 @@ abstract class DB_PDO extends PDO { */ public function get_query_data($statement) { - $this->statement = $statement; + $this->statement =& $statement; // Execute the query $this->statement->execute(); diff --git a/sys/common/query_builder.php b/sys/common/query_builder.php index be95e2b..371199d 100644 --- a/sys/common/query_builder.php +++ b/sys/common/query_builder.php @@ -64,7 +64,14 @@ class Query_Builder { break; case "firebird": - $this->db = new $dbtype("{$params->host}:{$params->file}", $params->user, $params->pass); + if(in_array('firebird', pdo_drivers())) + { + $this->db = new $dbtype("host={$params->host};dbname={$params->file}", $params->user, $params->pass); + } + else + { + $this->db = new $dbtype("{$params->host}:{$params->file}", $params->user, $params->pass); + } break; } } diff --git a/sys/databases/firebird-ibase.php b/sys/databases/firebird-ibase.php index ce4671b..7ae42d6 100644 --- a/sys/databases/firebird-ibase.php +++ b/sys/databases/firebird-ibase.php @@ -19,7 +19,8 @@ */ class firebird extends DB_PDO { - protected $conn, $statement, $trans, $count, $result; + protected $statement, $trans, $count, $result; + public static $conn; /** * Open the link to the database @@ -30,7 +31,13 @@ class firebird extends DB_PDO { */ public function __construct($dbpath, $user='sysdba', $pass='masterkey') { - $this->conn = ibase_connect($dbpath, $user, $pass, 'utf-8'); + self::$conn = ibase_connect($dbpath, $user, $pass, 'utf-8'); + + if ( ! self::$conn) + { + throw new PDOException(ibase_errmsg()); + } + $class = __CLASS__."_sql"; $this->sql = new $class; @@ -43,7 +50,7 @@ class firebird extends DB_PDO { */ public function __destruct() { - @ibase_close($this->conn); + @ibase_close(self::$conn); @ibase_free_result($this->statement); } @@ -73,7 +80,7 @@ class firebird extends DB_PDO { public function query($sql) { $this->count = 0; - $this->statement = ibase_query($this->conn, $sql); + $this->statement = ibase_query(self::$conn, $sql); return $this->statement; } @@ -135,7 +142,7 @@ class firebird extends DB_PDO { */ public function prepare($query, $options=NULL) { - $this->statement = ibase_prepare($this->conn, $query); + $this->statement = ibase_prepare(self::$conn, $query); return $this->statement; } @@ -202,7 +209,7 @@ SQL; */ public function affected_rows($statement="") { - return ibase_affected_rows($this->conn); + return ibase_affected_rows(self::$conn); } // -------------------------------------------------------------------------- @@ -235,7 +242,7 @@ SQL; */ public function beginTransaction() { - if(($this->trans =& ibase_trans($this->conn)) !== NULL) + if(($this->trans =& ibase_trans(self::$conn)) !== NULL) { return TRUE; } diff --git a/sys/databases/firebird.php b/sys/databases/firebird.php index 1461b91..1412df2 100644 --- a/sys/databases/firebird.php +++ b/sys/databases/firebird.php @@ -21,7 +21,7 @@ class Firebird extends DB_PDO { */ public function __construct($dbpath, $user='sysdba', $pass='masterkey') { - parent::__construct("firebird:{$dbpath}", $user, $pass); + parent::__construct("firebird:dbname={$dbpath}", $user, $pass); $class = __CLASS__."_sql"; $this->sql = new $class; @@ -60,7 +60,7 @@ SQL; $tables = array(); - while($row = $this->fetch(PDO::FETCH_ASSOC)) + while($row = $this->statement->fetch(PDO::FETCH_ASSOC)) { $tables[] = $row['RDB$RELATION_NAME']; } @@ -87,7 +87,7 @@ SQL; $tables = array(); - while($row = $this->fetch(PDO::FETCH_ASSOC)) + while($row = $this->statement->fetch(PDO::FETCH_ASSOC)) { $tables[] = $row['RDB$RELATION_NAME']; } @@ -111,7 +111,7 @@ SQL; } //Fetch all the rows for the result - $this->result = $this->fetchAll(); + $this->result = $this->statement->fetchAll(); return count($this->result); } @@ -163,7 +163,7 @@ SQL; { $sql = 'SELECT * FROM "'.trim($t).'"'; $res = $this->query($sql); - $obj_res = $this->fetchAll(PDO::FETCH_ASSOC); + $obj_res = $res->fetchAll(PDO::FETCH_ASSOC); unset($res); diff --git a/tests/databases/firebird.php b/tests/databases/firebird.php index 507a6eb..8a7a07b 100644 --- a/tests/databases/firebird.php +++ b/tests/databases/firebird.php @@ -38,7 +38,7 @@ class FirebirdTest extends UnitTestCase { function tearDown() { - unset($this->db); + //unset($this->db); unset($this->tables); } @@ -98,8 +98,8 @@ class FirebirdTest extends UnitTestCase { INSERT INTO "create_test" ("id", "key", "val") VALUES (?,?,?) SQL; - $this->db->prepare($sql); - $this->db->execute(array(1,"booger's", "Gross")); + $query = $this->db->prepare($sql); + $query->execute(array(1,"booger's", "Gross")); } diff --git a/tests/index.php b/tests/index.php index 99dc92a..b1d8f62 100644 --- a/tests/index.php +++ b/tests/index.php @@ -41,6 +41,11 @@ $test_path = "./databases/"; foreach(pdo_drivers() as $d) { + if($d === 'firebird') + { + continue; + } + $src_file = "{$src_path}{$d}.php"; if(is_file($src_file)) @@ -52,7 +57,7 @@ foreach(pdo_drivers() as $d) } // Load Firebird if there is support -if(function_exists('ibase_connect') && ! in_array('firebird', pdo_drivers())) +if(function_exists('ibase_connect'))// && ! in_array('firebird', pdo_drivers())) { require_once("{$src_path}firebird-ibase.php"); require_once("{$src_path}firebird_sql.php"); diff --git a/tests/test_dbs/FB_TEST_DB.FDB b/tests/test_dbs/FB_TEST_DB.FDB index 7e44e4f..9372bee 100755 Binary files a/tests/test_dbs/FB_TEST_DB.FDB and b/tests/test_dbs/FB_TEST_DB.FDB differ