init
This commit is contained in:
parent
f03431dc70
commit
73c7f7f587
13
index.php
13
index.php
|
@ -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 "
|
||||
|
||||
";
|
Loading…
Reference in New Issue