Deduplicate error methods in Firebird_Result class
This commit is contained in:
parent
9f93d1ce35
commit
3cc260b779
@ -207,7 +207,7 @@ class Firebird extends Abstract_Driver {
|
||||
$err_string = \fbird_errmsg() . "Last query:" . $this->last_query;
|
||||
if ($this->statement_link === FALSE) throw new \PDOException($err_string, \fbird_errcode(), NULL);
|
||||
|
||||
$this->statement = new FireBird_Result($this->statement_link);
|
||||
$this->statement = new FireBird_Result($this->statement_link, $this);
|
||||
|
||||
return $this->statement;
|
||||
}
|
||||
@ -229,7 +229,7 @@ class Firebird extends Abstract_Driver {
|
||||
// Throw the error as an exception
|
||||
if ($this->statement_link === FALSE) throw new \PDOException(\fbird_errmsg(), \fbird_errcode(), NULL);
|
||||
|
||||
$this->statement = new FireBird_Result($this->statement_link);
|
||||
$this->statement = new FireBird_Result($this->statement_link, $this);
|
||||
|
||||
return $this->statement;
|
||||
}
|
||||
|
@ -45,14 +45,23 @@ class Firebird_Result extends \PDOStatement {
|
||||
*/
|
||||
private $result = array();
|
||||
|
||||
/**
|
||||
* Reference to the db drive to de-duplicate error functions
|
||||
*
|
||||
* @var \Query\Driver\Firebird
|
||||
*/
|
||||
private $db;
|
||||
|
||||
/**
|
||||
* Create the object by passing the resource for
|
||||
* the query
|
||||
*
|
||||
* @param resource $link
|
||||
* @param [\Query\Driver\Firebird] $db
|
||||
*/
|
||||
public function __construct($link)
|
||||
public function __construct($link, Driver_Interface $db = NULL)
|
||||
{
|
||||
if ( ! is_null($db)) $this->db = $db;
|
||||
$this->statement = $link;
|
||||
$this->setFetchMode(\PDO::FETCH_ASSOC);
|
||||
$this->row = -1;
|
||||
@ -271,7 +280,7 @@ class Firebird_Result extends \PDOStatement {
|
||||
*/
|
||||
public function errorCode()
|
||||
{
|
||||
return \fbird_errcode();
|
||||
return $this->db->errorCode();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
@ -283,10 +292,7 @@ class Firebird_Result extends \PDOStatement {
|
||||
*/
|
||||
public function errorInfo()
|
||||
{
|
||||
$code = \fbird_errcode();
|
||||
$msg = \fbird_errmsg();
|
||||
|
||||
return array(0, $code, $msg);
|
||||
return $this->db->errorInfo();
|
||||
}
|
||||
}
|
||||
// End of firebird_result.php
|
@ -34,10 +34,9 @@ class Firebird_Util extends Abstract_Util {
|
||||
* @param string $name
|
||||
* @param array $fields
|
||||
* @param array $constraints
|
||||
* @param array $indexes
|
||||
* @return string
|
||||
*/
|
||||
public function create_table($name, $fields, array $constraints=array(), array $indexes=array())
|
||||
public function create_table($name, $fields, array $constraints=array())
|
||||
{
|
||||
$column_array = array();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user