From 11060a27717f5254c471e27f714bec15d9d154b5 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Wed, 8 Feb 2012 15:05:28 -0500 Subject: [PATCH] Firebird tests, added dev guide --- DEV_README.md | 33 ++++++++++++++++++++++++++++++++ src/databases/firebird.php | 5 ++++- src/databases/firebird_manip.php | 6 +++--- tests/databases/firebird.php | 15 +++++++++++++-- 4 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 DEV_README.md diff --git a/DEV_README.md b/DEV_README.md new file mode 100644 index 0000000..4d9a63c --- /dev/null +++ b/DEV_README.md @@ -0,0 +1,33 @@ +#Developer Notes + +##Programming Style +Follow the CodeIgniter [Style Guide](https://github.com/timw4mail/CodeIgniter/blob/develop/user_guide_src/source/general/styleguide.rst#class-and-file-names-using-common-words) - and: + +* Do not use spaces to align code +* Do not use `global`, `eval` +* Do not use the error suppressor `@` +* Add a docblock to every method + +## PHP-Gtk Resources +* [Reference](http://gtk.php.net/manual/en/reference.php) +* [Official Tutorials](http://gtk.php.net/manual/en/tutorials.php) +* [Community site](http://php-gtk.eu/) - Contains various tutorials + +## Database reference material +### Firebird + +* [Interbase 6 Lang Ref](http://fbclient.googlecode.com/files/LangRef.pdf) - SQL Syntax (pdf) +* [Firebird Lang Update Ref](http://www.firebirdsql.org/file/documentation/reference_manuals/reference_material/html/langrefupd25.html) - SQL Syntax Updates + +### MySQL +* [MySQL Syntax](http://dev.mysql.com/doc/refman/5.1/en/sql-syntax.html) +* [Optimizing SQL Statements](http://dev.mysql.com/doc/refman/5.1/en/statement-optimization.html) + +### PostgreSQL +* [PostgreSQL Syntax](http://www.postgresql.org/docs/9.0/interactive/sql.html) +* [Performance Tips](http://www.postgresql.org/docs/9.0/interactive/performance-tips.html) + +### SQLite + +* [SQL Syntax](http://www.sqlite.org/lang.html) +* [Pragma SQL Syntax](http://www.sqlite.org/pragma.html) - Internal / Performance Stuff \ No newline at end of file diff --git a/src/databases/firebird.php b/src/databases/firebird.php index 3f8d4e6..400ae86 100644 --- a/src/databases/firebird.php +++ b/src/databases/firebird.php @@ -32,6 +32,9 @@ class firebird { function __construct($dbpath, $user="sysdba", $pass="masterkey") { $this->conn = ibase_connect($dbpath, $user, $pass); + + $class = __CLASS__."_manip"; + $this->manip = new $class; } /** @@ -136,7 +139,7 @@ class firebird { $sql="SELECT rdb\$relation_name FROM rdb\$relations WHERE rdb\$relation_name NOT LIKE 'RDB\$%'"; $this->statement = $this->query($sql); - return $this->fetch(PDO::FETCH_NUM); + return $this->fetch(); } /** diff --git a/src/databases/firebird_manip.php b/src/databases/firebird_manip.php index a931004..d5040aa 100644 --- a/src/databases/firebird_manip.php +++ b/src/databases/firebird_manip.php @@ -39,7 +39,7 @@ class firebird_manip extends db_manip{ // 'constraint' => ..., // 'index' => ..., // ) - foreach($columns as $colname => $type) + foreach($fields as $colname => $type) { if(is_numeric($colname)) { @@ -63,7 +63,7 @@ class firebird_manip extends db_manip{ foreach($column_array as $n => $props) { $str = "{$n} "; - $str .= (isset($props['type'])) ? "{$props['type']}" : ""; + $str .= (isset($props['type'])) ? "{$props['type']} " : ""; $str .= (isset($props['constraint'])) ? "{$props['constraint']} " : ""; $columns[] = $str; @@ -85,7 +85,7 @@ class firebird_manip extends db_manip{ */ function delete_table($name) { - return "DELETE TABLE {$name}"; + return "DROP TABLE \"{$name}\""; } } diff --git a/tests/databases/firebird.php b/tests/databases/firebird.php index 723fd44..e1f3496 100644 --- a/tests/databases/firebird.php +++ b/tests/databases/firebird.php @@ -36,14 +36,25 @@ class FirebirdTest extends UnitTestCase { { $this->assertIsA($this->db, 'Firebird'); } + + function TestGetTables() + { + $tables = $this->db->get_tables(); + + print_r($tables); + } function TestCreateDatabase() { - + //Attempt to create the table + $sql = $this->db->manip->create_table('create_test', array('id' => 'SMALLINT'), array('id' => 'PRIMARY KEY')); + //echo '
'.$sql.'
'; + $this->db->query($sql); } function TestDeleteDatabase() { - + $sql = $this->db->manip->delete_table('create_test'); + $this->db->query($sql); } } \ No newline at end of file