diff --git a/src/databases/firebird.php b/src/databases/firebird.php index 618763c..ef7f72f 100644 --- a/src/databases/firebird.php +++ b/src/databases/firebird.php @@ -157,24 +157,6 @@ class firebird { function num_rows() { // TODO: Implement - } - -} - -/** - * Database manipulation class - */ -class firebird_manip extends firebird { - - function __construct($db, $user="sysdba", $pass="masterkey") - { - parent::__construct($db, $user, $pass); - } - - function create_table($name, $fields, $constraints=array()) - { - $sql = "CREATE TABLE {$name}"; - } - + } } // End of firebird.php \ No newline at end of file diff --git a/src/databases/firebird_manip.php b/src/databases/firebird_manip.php new file mode 100644 index 0000000..674b7e0 --- /dev/null +++ b/src/databases/firebird_manip.php @@ -0,0 +1,33 @@ + type pairs - * @param array $constraints // column => constraint pairs - * @param array $indexes // column => index pairs - * @return string - */ - function create_table($name, $columns, $constraints, $indexes) - { - $column_array = array(); - - // Reorganize into an array indexed with column information - // Eg $column_array[$colname] = array( - // 'type' => ..., - // 'constraint' => ..., - // 'index' => ..., - // ) - foreach($columns as $colname => $type) - { - if(is_numeric($colname)) - { - $colname = $type; - } - - $column_array[$colname] = array(); - $column_array[$colname]['type'] = ($type !== $colname) ? $type : ''; - } - - if( ! empty($constraints)) - { - foreach($constraints as $col => $const) - { - $column_array[$col]['constraint'] = $const; - } - } - - if( ! empty($indexes)) - { - foreach($indexes as $col => $ind) - { - $column_array[$col]['index'] = $ind; - } - } - - // Generate the sql for the creation of the table - $sql = "CREATE TABLE {$name} ("; - $sql .= ")"; - } - - /** - * Create an sqlite database file - * - * @param $path - */ - function create_db($path) - { - // Create the file if it doesn't exist - if( ! file_exists($path)) - { - touch($path); - } - } -} \ No newline at end of file +//End of sqlite.php \ No newline at end of file diff --git a/src/databases/sqlite_manip.php b/src/databases/sqlite_manip.php new file mode 100644 index 0000000..faf0e35 --- /dev/null +++ b/src/databases/sqlite_manip.php @@ -0,0 +1,90 @@ + type pairs + * @param array $constraints // column => constraint pairs + * @param array $indexes // column => index pairs + * @return string + */ + function create_table($name, $columns, $constraints, $indexes) + { + $column_array = array(); + + // Reorganize into an array indexed with column information + // Eg $column_array[$colname] = array( + // 'type' => ..., + // 'constraint' => ..., + // 'index' => ..., + // ) + foreach($columns as $colname => $type) + { + if(is_numeric($colname)) + { + $colname = $type; + } + + $column_array[$colname] = array(); + $column_array[$colname]['type'] = ($type !== $colname) ? $type : ''; + } + + if( ! empty($constraints)) + { + foreach($constraints as $col => $const) + { + $column_array[$col]['constraint'] = $const; + } + } + + if( ! empty($indexes)) + { + foreach($indexes as $col => $ind) + { + $column_array[$col]['index'] = $ind; + } + } + + // Generate the sql for the creation of the table + $sql = "CREATE TABLE {$name} ("; + $sql .= ")"; + } + + /** + * Create an sqlite database file + * + * @param $path + */ + function create_db($path) + { + // Create the file if it doesn't exist + if( ! file_exists($path)) + { + touch($path); + } + } +} +//End of sqlite_manip.php \ No newline at end of file diff --git a/src/index.php b/src/index.php index 9a4e85e..cb96fcf 100644 --- a/src/index.php +++ b/src/index.php @@ -92,7 +92,8 @@ foreach(pdo_drivers() as $d) if(is_file($file)) { - require_once($file); + require_once("{$path}{$d}.php"); + require_once("{$path}{$d}_manip.php"); } } @@ -100,6 +101,7 @@ foreach(pdo_drivers() as $d) if(function_exists('ibase_connect')) { require_once("{$path}firebird.php"); + require_once("{$path}firebird_manip.php"); } // -------------------------------------------------------------------------- diff --git a/tests/index.php b/tests/index.php index cdcba97..8584e85 100644 --- a/tests/index.php +++ b/tests/index.php @@ -40,14 +40,13 @@ $test_path = "./databases/"; foreach(pdo_drivers() as $d) { - $src_file = "{$src_path}{$d}.php"; - $test_file = "{$test_path}{$d}.php"; if(is_file($src_file)) { - require_once($src_file); - require_once($test_file); + require_once("{$src_path}{$d}.php"); + require_once("{$src_path}{$d}_manip.php"); + require_once("{$test_path}{$d}.php"); } } @@ -55,5 +54,6 @@ foreach(pdo_drivers() as $d) if(function_exists('ibase_connect')) { require_once("{$src_path}firebird.php"); + require_once("{$src_path}firebird_manip.php"); require_once("{$test_path}firebird.php"); } \ No newline at end of file diff --git a/tests/test_dbs/FB_TEST_DB.FDB b/tests/test_dbs/FB_TEST_DB.FDB index a62ad6b..a57eef1 100755 Binary files a/tests/test_dbs/FB_TEST_DB.FDB and b/tests/test_dbs/FB_TEST_DB.FDB differ