first commit
This commit is contained in:
commit
d21ca3e6ab
10 changed files with 753 additions and 0 deletions
36
src/Venom/Database/DatabaseHandler.php
Normal file
36
src/Venom/Database/DatabaseHandler.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?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';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue