36 lines
707 B
PHP
36 lines
707 B
PHP
|
<?php
|
||
|
|
||
|
|
||
|
namespace Venom\Database;
|
||
|
|
||
|
|
||
|
use PDO;
|
||
|
|
||
|
/**
|
||
|
* Singleton DatabaseHandler... make sure we only have one connection to the database..
|
||
|
* @package Venom\Database
|
||
|
*/
|
||
|
class DatabaseHandler
|
||
|
{
|
||
|
private static ?self $instance = null;
|
||
|
private ?PDO $db = null;
|
||
|
|
||
|
public static function get(): DatabaseHandler
|
||
|
{
|
||
|
if (self::$instance === null) {
|
||
|
self::$instance = new self();
|
||
|
}
|
||
|
return self::$instance;
|
||
|
}
|
||
|
|
||
|
public function init(array $data): void
|
||
|
{
|
||
|
//init instance with the current data... only working if the db is not init!
|
||
|
if ($this->db != null) {
|
||
|
return;
|
||
|
}
|
||
|
$dsn = '%s:host=%s;dbname=%s;port=%s';
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|