diff options
author | Silvio <silvio@devlet.com.br> | 2010-03-30 12:01:20 -0300 |
---|---|---|
committer | Silvio <silvio@devlet.com.br> | 2010-03-30 12:01:20 -0300 |
commit | 1d960150de785261da282e1505360e97ee144493 (patch) | |
tree | 349dd6782ba56be4f64ff31b7b587759cad2f154 /classes/PhpIsisDb.php | |
parent | f3af45962c3b26782479f3b8ab5fa09d62a0f483 (diff) | |
download | cinisis-1d960150de785261da282e1505360e97ee144493.tar.gz cinisis-1d960150de785261da282e1505360e97ee144493.tar.bz2 |
Adding PhpIsis implementation of IsisDb
Diffstat (limited to 'classes/PhpIsisDb.php')
-rw-r--r-- | classes/PhpIsisDb.php | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/classes/PhpIsisDb.php b/classes/PhpIsisDb.php new file mode 100644 index 0000000..4e1aaf0 --- /dev/null +++ b/classes/PhpIsisDb.php @@ -0,0 +1,51 @@ +<?php + +/** + * PHP-Isis implementation of IsisDb. + */ +class PhpIsisDb implements IsisDb { + var $db; + var $format; + + public function __construct($schema) { + // Save db schema. + $this->format = $schema; + + // Setup $fdt used by malete. + foreach ($schema['fields'] as $field => $info) { + $this->fdt[$field] = $info['name']; + } + + // Open the database. + $name = $schema['db']['name']; + $this->db = isis_open("db/$name/$name"); + } + + public function read($id) { + $results = isis_search('$', $this->db); + if (!isis_data_seek($results, $id)) { + return FALSE; + } + + return $this->tag(isis_fetch_array($results)); + } + + public function rows() { + return isis_last_mfn($this->db); + } + + public function default_schema() { + return SchemaDb::default_schema(); + } + + // Tag results of a db query. + function tag($results) { + foreach ($results as $key => $value) { + if ($key != 'mfn') { + $name = $this->format['fields'][$key]['name']; + $data[$name] = $value; + } + } + return $data; + } +} |