mirror of
https://github.com/standardebooks/web.git
synced 2025-07-14 10:31:59 -04:00
Replace static GetOrCreate with GetByNameOrCreate
This commit is contained in:
parent
4a1a4efb24
commit
cc8de11ca4
3 changed files with 10 additions and 10 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue