diff --git a/core/abstract/abstract_driver.php b/core/abstract/abstract_driver.php index a45138e..5989118 100644 --- a/core/abstract/abstract_driver.php +++ b/core/abstract/abstract_driver.php @@ -419,6 +419,19 @@ abstract class Abstract_Driver extends \PDO implements Driver_Interface { // -------------------------------------------------------------------------- + /** + * Retrieve indexes for the table + * + * @param string $table + * @return array + */ + public function get_indexes($table) + { + return $this->driver_query($this->sql->index_list($table), FALSE); + } + + // -------------------------------------------------------------------------- + /** * Retrieve list of data types for the database * diff --git a/core/abstract/abstract_table.php b/core/abstract/abstract_table.php index 9943364..26e35bc 100644 --- a/core/abstract/abstract_table.php +++ b/core/abstract/abstract_table.php @@ -47,7 +47,8 @@ abstract class Abstract_Table { */ public function set_options(Array $options) { - $type = end(explode('_', get_class($this))); + $class_segments = explode('_', get_class($this)); + $type = end($class_segments); foreach($options as $option => $value) { diff --git a/core/interfaces/sql_interface.php b/core/interfaces/sql_interface.php index fea8f3f..1ff40dc 100644 --- a/core/interfaces/sql_interface.php +++ b/core/interfaces/sql_interface.php @@ -127,9 +127,17 @@ interface SQL_Interface { * table * * @parma string $table - * @return string + * @return array */ public function fk_list($table); + /** + * Get the list of indexes for the current table + * + * @param string $table + * @return array + */ + public function index_list($table); + } // End of sql_interface.php \ No newline at end of file diff --git a/tests/core/db_test.php b/tests/core/db_test.php index c8b9586..ee8fe68 100644 --- a/tests/core/db_test.php +++ b/tests/core/db_test.php @@ -43,15 +43,7 @@ abstract class DBTest extends Query_TestCase { $this->assertTrue(is_array($tables)); } - - // -------------------------------------------------------------------------- - - public function testCreateTransaction() - { - $res = $this->db->beginTransaction(); - $this->assertTrue($res); - } - + // -------------------------------------------------------------------------- public function testBackupData() @@ -83,5 +75,13 @@ abstract class DBTest extends Query_TestCase { $this->assertTrue(is_array($keys)); } + // -------------------------------------------------------------------------- + + public function testGetIndexes() + { + $keys = $this->db->get_indexes('test'); + $this->assertTrue(is_array($keys)); + } + } // End of db_test.php \ No newline at end of file diff --git a/tests/databases/firebird/FirebirdQBTest.php b/tests/databases/firebird/FirebirdQBTest.php index aae1d9b..22c215b 100644 --- a/tests/databases/firebird/FirebirdQBTest.php +++ b/tests/databases/firebird/FirebirdQBTest.php @@ -140,7 +140,11 @@ class FirebirdQBTest extends QBTest { public function testBackupStructure() { - $this->assertEquals('', $this->db->util->backup_structure()); + + $existing = QTEST_DIR.QDS.'db_files'.QDS.'FB_TEST_DB.FDB'; + $backup = QTEST_DIR.QDS.'db_files'.QDS.'FB_TEST_BKP.FDB'; + + $this->assertTrue($this->db->util->backup_structure($existing, $backup)); } // -------------------------------------------------------------------------- diff --git a/tests/databases/firebird/FirebirdTest.php b/tests/databases/firebird/FirebirdTest.php index e58d1a3..297742c 100644 --- a/tests/databases/firebird/FirebirdTest.php +++ b/tests/databases/firebird/FirebirdTest.php @@ -109,6 +109,7 @@ class FirebirdTest extends DBtest { public function testCreateTable() { + //Attempt to create the table $sql = $this->db->util->create_table('create_delete', array( 'id' => 'SMALLINT', @@ -314,4 +315,9 @@ SQL; { $this->assertFalse($this->db->setAttribute(47, 'foo')); } + + public function testLastInsertId() + { + $this->assertEqual(0, $this->db->lastInsertId('NEWTABLE_SEQ')); + } } \ No newline at end of file diff --git a/tests/databases/pgsql/PgSQLTest.php b/tests/databases/pgsql/PgSQLTest.php index 4b9dd0a..e7ee7ae 100644 --- a/tests/databases/pgsql/PgSQLTest.php +++ b/tests/databases/pgsql/PgSQLTest.php @@ -62,10 +62,19 @@ class PgTest extends DBTest { // -------------------------------------------------------------------------- + public function DataCreate() + { + $this->db->exec(file_get_contents(QTEST_DIR.'/db_files/pgsql.sql')); + } + + // -------------------------------------------------------------------------- + public function testCreateTable() { if (empty($this->db)) return; + $this->DataCreate(); + // Drop the table(s) if they exist $sql = 'DROP TABLE IF EXISTS "create_test"'; $this->db->query($sql); diff --git a/tests/databases/sqlite/SqliteTest.php b/tests/databases/sqlite/SqliteTest.php index 6f38a00..a37c9e4 100644 --- a/tests/databases/sqlite/SqliteTest.php +++ b/tests/databases/sqlite/SqliteTest.php @@ -224,7 +224,7 @@ SQL; public function testGetDBs() { - $this->assertNull($this->db->get_dbs()); + $this->assertTrue(is_array($this->db->get_dbs())); } // -------------------------------------------------------------------------- @@ -261,16 +261,5 @@ SQL; $sql = $this->db->sql->sequence_list(); $this->assertEqual(NULL, $sql); - - $sql = $this->db->sql->fk_list('create_test'); - $this->assertEqual(NULL, $sql); - } - - // -------------------------------------------------------------------------- - - public function testGetFKs() - { - $keys = $this->db->get_fks('create_test'); - $this->assertNull($keys); } } \ No newline at end of file diff --git a/tests/db_files/FB_TEST_DB.FDB b/tests/db_files/FB_TEST_DB.FDB index e8a33ae..ad29571 100755 Binary files a/tests/db_files/FB_TEST_DB.FDB and b/tests/db_files/FB_TEST_DB.FDB differ