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))
|
||||
@ -83,6 +83,14 @@ class Firebird extends DB_PDO {
|
||||
$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)
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user