aboutsummaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
Diffstat (limited to 'classes')
-rw-r--r--classes/CinIsis.php40
-rw-r--r--classes/MaleteDb.php4
2 files changed, 42 insertions, 2 deletions
diff --git a/classes/CinIsis.php b/classes/CinIsis.php
new file mode 100644
index 0000000..300bd61
--- /dev/null
+++ b/classes/CinIsis.php
@@ -0,0 +1,40 @@
+<?php
+
+/**
+ * CinIsis main class.
+ */
+class CinIsis {
+ /**
+ * @var $db
+ * Database resource.
+ */
+ var $db;
+
+ /**
+ * @var $implementation
+ * Database implementation.
+ */
+ var $implementation;
+
+ /**
+ * Constructor.
+ *
+ * @param $config
+ * Alternative config file (defaults to 'config/config.yaml').
+ */
+ function __construct($config = NULL) {
+ if ($config == NULL) {
+ $config = 'config/config.yaml';
+ }
+
+ // Load configuration.
+ $config = Spyc::YAMLLoad($config);
+
+ // Load database schema.
+ $schema = Spyc::YAMLLoad('schemas/'. $config['database'] .'.yaml');
+
+ // Setup database connection.
+ $this->implementation = $config['implementation'] .'Db';
+ $this->db = new $this->implementation($schema);
+ }
+}
diff --git a/classes/MaleteDb.php b/classes/MaleteDb.php
index 0628e9e..a2d45aa 100644
--- a/classes/MaleteDb.php
+++ b/classes/MaleteDb.php
@@ -71,11 +71,11 @@ class MaleteDb implements IsisDb {
* @see IsisDb::read()
*/
public function rows() {
- $id = 1;
+ $id = 0;
while($this->db->read($id)) {
$id++;
}
- return $id - 1;
+ return $id;
}
/**