add template files and compose file, fix syntax errors in template

This commit is contained in:
boris
2024-11-21 12:33:19 +00:00
parent f9d57038bf
commit b64c6d835e
55 changed files with 16384 additions and 7288 deletions

35
Models/Database.php Normal file
View File

@@ -0,0 +1,35 @@
<?php
class Database {
/**
* @var Database
*/
protected static $_dbInstance = null;
/**
* @var PDO
*/
protected $_dbHandle;
public function getDbConnection(): PDO
{
return $this->_dbHandle;
}
public static function getInstance(): ?Database
{
if(self::$_dbInstance == null) {
self::$_dbInstance = new self();
}
return self::$_dbInstance;
}
private function __construct() {
try {
$this->_dbHandle = new PDO("sqlite:Databases/ecobuddy.sqlite");
}
catch (PDOException $e) {
echo $e->getMessage();
}
}
public function __destruct() {
$this->_dbHandle = null; // destroys the PDO handle when no longer needed
}
}