mirror of
https://github.com/standardebooks/web.git
synced 2025-07-14 18:42:00 -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
|
@ -24,19 +24,19 @@ class LocSubject extends Tag{
|
|||
$this->LocSubjectId = Db::GetLastInsertedId();
|
||||
}
|
||||
|
||||
public static function GetOrCreate(LocSubject $locSubject): LocSubject{
|
||||
public function GetByNameOrCreate(string $name): LocSubject{
|
||||
$result = Db::Query('
|
||||
SELECT *
|
||||
from LocSubjects
|
||||
where Name = ?
|
||||
', [$locSubject->Name], 'LocSubject');
|
||||
', [$name], 'LocSubject');
|
||||
|
||||
if(isset($result[0])){
|
||||
return $result[0];
|
||||
}
|
||||
else{
|
||||
$locSubject->Create();
|
||||
return $locSubject;
|
||||
$this->Create();
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue