Firebird tests, added dev guide

This commit is contained in:
Timothy Warren 2012-02-08 15:05:28 -05:00
parent d8b4424c0f
commit 11060a2771
4 changed files with 53 additions and 6 deletions

33
DEV_README.md Normal file
View File

@ -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

View File

@ -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();
}
/**

View File

@ -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))
{
@ -85,7 +85,7 @@ class firebird_manip extends db_manip{
*/
function delete_table($name)
{
return "DELETE TABLE {$name}";
return "DROP TABLE \"{$name}\"";
}
}

View File

@ -37,13 +37,24 @@ 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 '<br />'.$sql.'<br />';
$this->db->query($sql);
}
function TestDeleteDatabase()
{
$sql = $this->db->manip->delete_table('create_test');
$this->db->query($sql);
}
}