This commit is contained in:
Michał Sieciechowicz 2021-02-26 22:39:06 +01:00
parent f03431dc70
commit 73c7f7f587
1 changed files with 11 additions and 2 deletions

View File

@ -22,18 +22,21 @@ class ConnectionManager {
}
}
abstract class BaseModel {
protected static $sql;
protected static $sql = null;
public function __construct(ISqlBase $sql) {
self::$sql = $sql;
}
public static function Get(int $id) {
self::Initialize();
return ConnectionManager::Query(
self::$sql->Get(),
[],
get_called_class());
}
abstract private static function Initialize();
}
class JobSql implements ISqlBase {
@ -47,13 +50,19 @@ class Job extends BaseModel {
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);
echo "
";
echo Job::Get(10);
var_dump(Job::Get(10));
echo "
";