diff options
author | Silvio <silvio@devlet.com.br> | 2010-03-26 18:22:33 -0300 |
---|---|---|
committer | Silvio <silvio@devlet.com.br> | 2010-03-26 18:22:33 -0300 |
commit | bac9ab414127873b058d0b2ff3902399ef5d646f (patch) | |
tree | 316a23d740297933cfc3798fd54c451aea5d7a18 /isis.php | |
parent | 7bceb19f1d291a283f3442b3880a8cc3abea7d48 (diff) | |
download | cinisis-bac9ab414127873b058d0b2ff3902399ef5d646f.tar.gz cinisis-bac9ab414127873b058d0b2ff3902399ef5d646f.tar.bz2 |
Adding isis db module
Diffstat (limited to 'isis.php')
-rw-r--r-- | isis.php | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/isis.php b/isis.php new file mode 100644 index 0000000..66b3b7d --- /dev/null +++ b/isis.php @@ -0,0 +1,86 @@ +<?php +/** + * Database procedures. + */ + +/** + * Schema format example. + */ +$schema = array( + 'db' => array( + 'name' => 'dbname', + ), + 'fields' => array( + 'field_name' => array( + 'id' => 1, + 'size' => 1000, + 'format' => 'numeric', + 'repeat' => TRUE, + 'subfields' => array( + 'a' => 'test', + 'b' => 'test2', + ), + ), + ), +); + +/** + * Generic interface for reading Isis databases. + */ +interface IsisDb { + // Constructor. + public function __construct($schema); + + // Return field data for a given entry. + public function fields($id); + + // Return subfield data for a given entry. + public function subfields($id); + + // Read an entry. + public function read($id); + + // Return number of rows in the database. + public function rows(); +} + +/** + * Malete implementation of IsisDb. + */ +class MaleteDb implements IsisDb { + var $fdt; + var $db; + var $format; + + public function __construct($schema) { + // Save db schema. + $format = $schema; + + // Setup $fdt used by malete. + foreach ($schema['fields'] as $field => $info) { + $fdt[$field] = $info['id']; + } + + // Open a database connection. + $db = new Isis_Db($fdt, $schema['db']['name'], new Isis_Server()); + } + + public function fields($id == NULL) { + } + + public function subfields($id == NULL) { + } + + // TODO: put result into $schema format. + public function read($id) { + if (!is_numeric($id) { + return FALSE; + } + return $this->$db->read($id); + } + + public function rows() { + } +} + +?> |