prepare($query); $stmt->execute($params); return $stmt->fetchObject($output); } } abstract class BaseModel { protected static $sql = null; public static function Get(int $id) { self::Initialize(); return ConnectionManager::Query( self::$sql->Get(), [], get_called_class()); } private static function Initialize() { if (self::$sql === null) { throw new Exception('sql not inited'); } } } class JobSql implements ISqlBase { public function Get(): string { return "Select * from jobs where id = :id"; } public static function Create() { return new Job(); } } class Job extends BaseModel { private static $sql = JobSql::Create(); public function __construct() { parent::__construct( new JobSql() ); } } $dns = 'pgsql:host=localhost;port=5432;dbname=dynamic_dev;user=test;password=pass123'; ConnectionManager::Connect($dns); echo " "; var_dump(Job::Get(10)); echo " ";