This commit is contained in:
Michał Sieciechowicz 2021-02-26 23:50:11 +01:00
parent 73c7f7f587
commit 09b51d0db7
1 changed files with 6 additions and 11 deletions

View File

@ -24,10 +24,6 @@ class ConnectionManager {
abstract class BaseModel {
protected static $sql = null;
public function __construct(ISqlBase $sql) {
self::$sql = $sql;
}
public static function Get(int $id) {
self::Initialize();
return ConnectionManager::Query(
@ -36,7 +32,11 @@ abstract class BaseModel {
get_called_class());
}
abstract private static function Initialize();
private static function Initialize() {
if (self::$sql === null) {
throw new Exception('sql not inited');
}
}
}
class JobSql implements ISqlBase {
@ -47,15 +47,10 @@ class JobSql implements ISqlBase {
}
class Job extends BaseModel {
private $sql = new JobSql();
public function __construct() {
parent::__construct( new JobSql() );
}
private static function Initialize() {
if (self::$sql === null) {
self::$sql = new JobSql();
}
}
}
$dns = 'pgsql:host=localhost;port=5432;dbname=dynamic_dev;user=test;password=pass123';
ConnectionManager::Connect($dns);