Replace static GetOrCreate with GetByNameOrCreate

This commit is contained in:
Mike Colagrosso 2024-04-21 22:55:01 -06:00 committed by Alex Cabal
parent 4a1a4efb24
commit cc8de11ca4
3 changed files with 10 additions and 10 deletions

View file

@ -44,19 +44,19 @@ class EbookTag extends Tag{
$this->TagId = Db::GetLastInsertedId();
}
public static function GetOrCreate(EbookTag $ebookTag): EbookTag{
public function GetByNameOrCreate(string $name): EbookTag{
$result = Db::Query('
SELECT *
from Tags
where Name = ?
', [$ebookTag->Name], 'EbookTag');
', [$name], 'EbookTag');
if(isset($result[0])){
return $result[0];
}
else{
$ebookTag->Create();
return $ebookTag;
$this->Create();
return $this;
}
}
}