diff options
Diffstat (limited to 'classes')
-rw-r--r-- | classes/MaleteDb.php | 44 | ||||
-rw-r--r-- | classes/PhpIsisDb.php | 39 | ||||
-rw-r--r-- | classes/SchemaDb.php | 6 |
3 files changed, 85 insertions, 4 deletions
diff --git a/classes/MaleteDb.php b/classes/MaleteDb.php index fd10c78..d420af6 100644 --- a/classes/MaleteDb.php +++ b/classes/MaleteDb.php @@ -4,10 +4,29 @@ * Malete implementation of IsisDb. */ class MaleteDb implements IsisDb { + /** + * @var $fdt + * Field description table. + */ var $fdt; + + /** + * @var $db + * Database resource. + */ var $db; + + /** + * @var $format + * Database format, derived from $schema. + */ var $format; + /** + * Constructor. + * + * @see IsisDb::__construct() + */ public function __construct($schema) { // Save db schema. $this->format = $schema; @@ -24,6 +43,11 @@ class MaleteDb implements IsisDb { } } + /** + * Read an entry. + * + * @see IsisDb::read() + */ public function read($id) { if (!is_numeric($id)) { return FALSE; @@ -37,6 +61,11 @@ class MaleteDb implements IsisDb { } } + /** + * Return number of rows in the database. + * + * @see IsisDb::read() + */ public function rows() { $id = 1; while($this->db->read($id)) { @@ -45,11 +74,24 @@ class MaleteDb implements IsisDb { return $id - 1; } + /** + * Return a default example schema. + * + * @see IsisDb::default_schema() + */ public function default_schema() { return SchemaDb::default_schema(); } - // Tag results of a db query. + /** + * Tag results of a db query. + * + * @param $results + * Database query results. + * + * @return + * Tagged database result. + */ function tag($results) { foreach ($results->val as $key => $value) { $field = $results->tag[$key]; diff --git a/classes/PhpIsisDb.php b/classes/PhpIsisDb.php index 4e1aaf0..78c9cf0 100644 --- a/classes/PhpIsisDb.php +++ b/classes/PhpIsisDb.php @@ -4,9 +4,23 @@ * PHP-Isis implementation of IsisDb. */ class PhpIsisDb implements IsisDb { + /** + * @var $db + * Database resource. + */ var $db; + + /** + * @var $format + * Database format, derived from $schema. + */ var $format; + /** + * Constructor. + * + * @see IsisDb::__construct() + */ public function __construct($schema) { // Save db schema. $this->format = $schema; @@ -21,6 +35,11 @@ class PhpIsisDb implements IsisDb { $this->db = isis_open("db/$name/$name"); } + /** + * Read an entry. + * + * @see IsisDb::read() + */ public function read($id) { $results = isis_search('$', $this->db); if (!isis_data_seek($results, $id)) { @@ -30,15 +49,33 @@ class PhpIsisDb implements IsisDb { return $this->tag(isis_fetch_array($results)); } + /** + * Return number of rows in the database. + * + * @see IsisDb::rows() + */ public function rows() { return isis_last_mfn($this->db); } + /** + * Return a default example schema. + * + * @see IsisDb::default_schema() + */ public function default_schema() { return SchemaDb::default_schema(); } - // Tag results of a db query. + /** + * Tag results of a db query. + * + * @param $results + * Database query results. + * + * @return + * Tagged database result. + */ function tag($results) { foreach ($results as $key => $value) { if ($key != 'mfn') { diff --git a/classes/SchemaDb.php b/classes/SchemaDb.php index ac5a40e..4cf77e6 100644 --- a/classes/SchemaDb.php +++ b/classes/SchemaDb.php @@ -2,8 +2,10 @@ class SchemaDb { /** - * Schema format example. - */ + * Return a default example schema. + * + * @see IsisDb::default_schema() + */ public function default_schema() { $schema = array( 'db' => array( |