aboutsummaryrefslogtreecommitdiff
path: root/ratatoeskr/sys/Database.php
diff options
context:
space:
mode:
Diffstat (limited to 'ratatoeskr/sys/Database.php')
-rw-r--r--ratatoeskr/sys/Database.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/ratatoeskr/sys/Database.php b/ratatoeskr/sys/Database.php
index 4f9014a..d9fc327 100644
--- a/ratatoeskr/sys/Database.php
+++ b/ratatoeskr/sys/Database.php
@@ -110,4 +110,24 @@ class Database
{
return (int)$this->pdo->lastInsertId();
}
+
+ /**
+ * Get the version of the database structure currently used.
+ * @return int
+ */
+ public function dbversion(): int
+ {
+ $tableName = $this->subPrefix("PREFIX_meta");
+
+ /* Is the meta table present? If no, the version is 0. */
+ $stmt = $this->query("SHOW TABLES LIKE ?", $tableName);
+ list($table) = $stmt->fetch();
+ if ($table != $tableName) {
+ return 0;
+ }
+
+ $stmt = $this->query("SELECT `value` FROM `PREFIX_meta` WHERE `key` = 'dbversion'");
+ $sqlrow = $stmt->fetch();
+ return (int)unserialize(base64_decode($sqlrow["value"]));
+ }
}