Fix some Firebird issues, and make util class available from the Query Builder class
This commit is contained in:
parent
d4e99aa5cd
commit
56ea38ccad
@ -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;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
@ -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
|
@ -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);
|
||||
}
|
||||
|
@ -191,4 +191,4 @@ class Firebird_Util extends DB_Util {
|
||||
return $output_sql;
|
||||
}
|
||||
}
|
||||
// End of firebird_util.php
|
||||
// End of firebird_util.php
|
Loading…
Reference in New Issue
Block a user