Update drivers with missing method
This commit is contained in:
parent
d06a3eda0d
commit
85b804adaa
@ -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
|
||||
*
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 <<<SQL
|
||||
SELECT "RDB\$INDEX_NAME", "RDB\$UNIQUE_FLAG", "RDB\$FOREIGN_KEY"
|
||||
FROM "RDB\$INDICES"
|
||||
WHERE "RDB\$RELATION_NAME"='{$table}'
|
||||
SQL;
|
||||
}
|
||||
}
|
||||
|
@ -87,12 +87,14 @@ class Firebird_Util extends Abstract_Util {
|
||||
/**
|
||||
* Create an SQL backup file for the current database's structure
|
||||
* @codeCoverageIgnore
|
||||
* @param string $db_path
|
||||
* @param string $new_file
|
||||
* @return string
|
||||
*/
|
||||
public function backup_structure()
|
||||
{
|
||||
// TODO Implement Backup structure function
|
||||
return '';
|
||||
list($db_path, $new_file) = func_get_args();
|
||||
return ibase_backup($this->get_service(), $db_path, $new_file, IBASE_BKP_METADATA_ONLY);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
@ -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
|
@ -258,6 +258,42 @@ SQL;
|
||||
JOIN "pg_attribute" "att2" ON
|
||||
"att2"."attrelid" = "con"."conrelid"
|
||||
AND "att2"."attnum" = "con"."parent"
|
||||
SQL;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Get the list of indexes for the current table
|
||||
*
|
||||
* @param string $table
|
||||
* @return array
|
||||
*/
|
||||
public function index_list($table)
|
||||
{
|
||||
return <<<SQL
|
||||
SELECT
|
||||
t.relname AS table_name,
|
||||
i.relname AS index_name,
|
||||
array_to_string(array_agg(a.attname), ', ') AS column_names
|
||||
FROM
|
||||
pg_class t,
|
||||
pg_class i,
|
||||
pg_index ix,
|
||||
pg_attribute a
|
||||
WHERE
|
||||
t.oid = ix.indrelid
|
||||
AND i.oid = ix.indexrelid
|
||||
AND a.attrelid = t.oid
|
||||
AND a.attnum = ANY(ix.indkey)
|
||||
AND t.relkind = 'r'
|
||||
AND t.relname = '{$table}'
|
||||
GROUP BY
|
||||
t.relname,
|
||||
i.relname
|
||||
ORDER BY
|
||||
t.relname,
|
||||
i.relname;
|
||||
SQL;
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ class SQLite_SQL extends Abstract_SQL {
|
||||
*/
|
||||
public function db_list()
|
||||
{
|
||||
return NULL;
|
||||
return 'PRAGMA database_list';
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
@ -185,7 +185,20 @@ SQL;
|
||||
*/
|
||||
public function fk_list($table)
|
||||
{
|
||||
return NULL;
|
||||
return 'PRAGMA foreign_key_list("' . $table . '")';
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Get the list of indexes for the current table
|
||||
*
|
||||
* @param string $table
|
||||
* @return array
|
||||
*/
|
||||
public function index_list($table)
|
||||
{
|
||||
return 'PRAGMA index_list("' . $table . '")';
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user