fix Model

This commit is contained in:
Michał Sieciechowicz 2022-02-03 09:47:17 +00:00
parent 9060e31a92
commit f5faf4df93
1 changed files with 7 additions and 2 deletions

View File

@ -8,6 +8,7 @@ abstract class Model {
protected static string $primaryKey = 'id';
protected static ?string $table = null;
protected static ?IQuery $query = null;
private static array $queryModels = [];
protected static array $fields = [];
@ -21,7 +22,7 @@ abstract class Model {
}
return $array;
}
public static function Instance(object $object): static {
$obj = new static;
$params = get_object_vars($object);
@ -32,7 +33,11 @@ abstract class Model {
}
protected static function QueryModel() {
return static::SetQueryModel();
if (!isset(static::$queryModels[static::class]))
if (static::$query === null) {
static::$queryModels[static::class] = static::SetQueryModel();
}
return static::$queryModels[static::class];
}
public static function GetTableName() {