From 85b804adaa9d9ea7a41a6ff8aadf0068e01dc5ea Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Tue, 8 Apr 2014 14:43:07 -0400 Subject: [PATCH] Update drivers with missing method --- drivers/firebird/firebird_driver.php | 32 ++++++++++ drivers/firebird/firebird_result.php | 2 + drivers/firebird/firebird_sql.php | 17 ++++++ drivers/firebird/firebird_util.php | 6 +- drivers/mysql/mysql_sql.php | 13 ++++ drivers/pgsql/pgsql_sql.php | 88 ++++++++++++++++++++-------- drivers/sqlite/sqlite_sql.php | 17 +++++- 7 files changed, 145 insertions(+), 30 deletions(-) diff --git a/drivers/firebird/firebird_driver.php b/drivers/firebird/firebird_driver.php index e357802..7ab838b 100644 --- a/drivers/firebird/firebird_driver.php +++ b/drivers/firebird/firebird_driver.php @@ -54,6 +54,13 @@ class Firebird extends Abstract_Driver { */ protected $conn = NULL; + /** + * Reference to the service resource + * + * @var resource + */ + protected $service = NULL; + /** * Open the link to the database * @@ -70,6 +77,7 @@ class Firebird extends Abstract_Driver { : '\\fbird_connect'; $this->conn = $connect_function($dbpath, $user, $pass, 'utf-8', 0); + $this->service = fbird_service_attach('localhost', $user, $pass); // Throw an exception to make this match other pdo classes if ( ! \is_resource($this->conn)) throw new \PDOException(\fbird_errmsg(), \fbird_errcode(), NULL); @@ -90,6 +98,30 @@ class Firebird extends Abstract_Driver { // -------------------------------------------------------------------------- + /** + * Cleanup some loose ends + * @codeCoverageIgnore + */ + public function __destruct() + { + fbird_service_detach($this->service); + fbird_close($this->conn); + } + + // -------------------------------------------------------------------------- + + /** + * Return service handle + * + * @return resource + */ + public function get_service() + { + return $this->service; + } + + // -------------------------------------------------------------------------- + /** * Empty a database table * diff --git a/drivers/firebird/firebird_result.php b/drivers/firebird/firebird_result.php index 980d471..54c5f54 100644 --- a/drivers/firebird/firebird_result.php +++ b/drivers/firebird/firebird_result.php @@ -254,8 +254,10 @@ class Firebird_Result extends \PDOStatement { // Get the number of rows for the select query if you can if ($rows === 0 && \is_resource($this->statement) && \get_resource_type($this->statement) === "interbase result") { + // @codeCoverageIgnoreStart $rows = \count($this->result); } + // @codeCoverageIgnoreEnd return $rows; } diff --git a/drivers/firebird/firebird_sql.php b/drivers/firebird/firebird_sql.php index f9b68fd..a70213b 100644 --- a/drivers/firebird/firebird_sql.php +++ b/drivers/firebird/firebird_sql.php @@ -297,6 +297,23 @@ SQL; AND d1.RDB\$DEPENDED_ON_NAME <> d2.RDB\$DEPENDED_ON_NAME AND d1.RDB\$FIELD_NAME <> d2.RDB\$FIELD_NAME AND rc.RDB\$RELATION_NAME = '{$table}' -- table name +SQL; + } + + // -------------------------------------------------------------------------- + + /** + * Get the list of indexes for the current table + * + * @param string $table + * @return array + */ + public function index_list($table) + { + return <<get_service(), $db_path, $new_file, IBASE_BKP_METADATA_ONLY); } // -------------------------------------------------------------------------- diff --git a/drivers/mysql/mysql_sql.php b/drivers/mysql/mysql_sql.php index 08fd8e4..81b96c2 100644 --- a/drivers/mysql/mysql_sql.php +++ b/drivers/mysql/mysql_sql.php @@ -209,5 +209,18 @@ class MySQL_SQL extends Abstract_SQL { WHERE `REFERENCED_TABLE_NAME` = '{$table}'; SQL; } + + // -------------------------------------------------------------------------- + + /** + * Get the list of indexes for the current table + * + * @param string $table + * @return array + */ + public function index_list($table) + { + return "SHOW INDEX IN {$table}"; + } } //End of mysql_sql.php \ No newline at end of file diff --git a/drivers/pgsql/pgsql_sql.php b/drivers/pgsql/pgsql_sql.php index b87e880..4643622 100644 --- a/drivers/pgsql/pgsql_sql.php +++ b/drivers/pgsql/pgsql_sql.php @@ -232,32 +232,68 @@ SQL; public function fk_list($table) { return <<