diff --git a/classes/query_builder.php b/classes/query_builder.php index 93c4c76..1148e8c 100644 --- a/classes/query_builder.php +++ b/classes/query_builder.php @@ -123,6 +123,7 @@ class Query_Builder implements iQuery_Builder { // Make things just slightly shorter $this->sql = $this->db->sql; + $this->util = $this->db->util; } // -------------------------------------------------------------------------- diff --git a/drivers/firebird/firebird_driver.php b/drivers/firebird/firebird_driver.php index 4e38bc4..66c2064 100644 --- a/drivers/firebird/firebird_driver.php +++ b/drivers/firebird/firebird_driver.php @@ -61,7 +61,7 @@ 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', 0); // Throw an exception to make this match other pdo classes if ( ! is_resource($this->conn)) @@ -82,6 +82,14 @@ class Firebird extends DB_PDO { $class = __CLASS__."_util"; $this->util = new $class($this); } + + /** + * Clean up database connections + */ + public function __destruct() + { + fbird_close($this->conn); + } // -------------------------------------------------------------------------- @@ -104,9 +112,15 @@ class Firebird extends DB_PDO { * * @param string $sql * @return $this + * @throws PDOException */ public function query($sql) { + if (empty($sql)) + { + throw new PDOException("Query method requires an sql query!"); + } + $this->statement_link = (isset($this->trans)) ? fbird_query($this->trans, $sql) : fbird_query($this->conn, $sql); @@ -114,7 +128,7 @@ class Firebird extends DB_PDO { // Throw the error as a exception if ($this->statement_link === FALSE) { - throw new PDOException(fbird_errmsg()); + throw new PDOException(fbird_errmsg() . "Last query:" . $this->last_query); } $this->statement = new FireBird_Result($this->statement_link); @@ -130,6 +144,7 @@ class Firebird extends DB_PDO { * @param string $query * @param array $options * @return $this + * @throws PDOException */ public function prepare($query, $options=NULL) { @@ -201,7 +216,7 @@ class Firebird extends DB_PDO { $query = $this->prepare($sql); // Set the statement in the class variable for easy later access - $this->statement_link =& $query; + $this->statement_link =& $query; return $query->execute($args); } @@ -283,4 +298,4 @@ class Firebird extends DB_PDO { return NULL; } } -// End of firebird_driver.php +// End of firebird_driver.php \ No newline at end of file diff --git a/drivers/firebird/firebird_result.php b/drivers/firebird/firebird_result.php index 8e77cc1..cc7861c 100644 --- a/drivers/firebird/firebird_result.php +++ b/drivers/firebird/firebird_result.php @@ -65,6 +65,9 @@ class Firebird_Result extends PDOStatement { { $this->result[] = $row; } + + // Free the result resource + fbird_free_result($link); } } @@ -247,7 +250,7 @@ class Firebird_Result extends PDOStatement { $rows = fbird_affected_rows(); // Get the number of rows for the select query if you can - if ($rows === FALSE && is_resource($link) && get_resource_type($link) === "interbase result") + if ($rows === FALSE && is_resource($this->statement) && get_resource_type($this->statement) === "interbase result") { $rows = count($this->result); } diff --git a/drivers/firebird/firebird_util.php b/drivers/firebird/firebird_util.php index b6db304..1f30973 100644 --- a/drivers/firebird/firebird_util.php +++ b/drivers/firebird/firebird_util.php @@ -191,4 +191,4 @@ class Firebird_Util extends DB_Util { return $output_sql; } } -// End of firebird_util.php +// End of firebird_util.php \ No newline at end of file