mirror of
https://github.com/standardebooks/web.git
synced 2025-07-07 07:10:29 -04:00
Contributor, EbookSource, GitCommit: Move INSERT statements to Create() methods
This commit is contained in:
parent
4aefe412f9
commit
2378320d0c
4 changed files with 45 additions and 37 deletions
|
@ -22,4 +22,23 @@ class Contributor{
|
|||
$instance->NacoafUrl = $nacoafUrl;
|
||||
return $instance;
|
||||
}
|
||||
|
||||
public function Create(): void{
|
||||
Db::Query('
|
||||
INSERT into Contributors (EbookId, Name, UrlName, SortName, WikipediaUrl, MarcRole, FullName,
|
||||
NacoafUrl, SortOrder)
|
||||
values (?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?)
|
||||
', [$this->EbookId, $this->Name, $this->UrlName, $this->SortName, $this->WikipediaUrl, $this->MarcRole, $this->FullName,
|
||||
$this->NacoafUrl, $this->SortOrder]);
|
||||
|
||||
$this->ContributorId = Db::GetLastInsertedId();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1605,16 +1605,7 @@ class Ebook{
|
|||
private function InsertGitCommits(): void{
|
||||
foreach($this->GitCommits as $commit){
|
||||
$commit->EbookId = $this->EbookId;
|
||||
|
||||
Db::Query('
|
||||
INSERT into GitCommits (EbookId, Created, Message, Hash)
|
||||
values (?,
|
||||
?,
|
||||
?,
|
||||
?)
|
||||
', [$commit->EbookId, $commit->Created, $commit->Message, $commit->Hash]);
|
||||
|
||||
$commit->GitCommitId = Db::GetLastInsertedId();
|
||||
$commit->Create();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1630,15 +1621,7 @@ class Ebook{
|
|||
private function InsertSources(): void{
|
||||
foreach($this->Sources as $source){
|
||||
$source->EbookId = $this->EbookId;
|
||||
|
||||
Db::Query('
|
||||
INSERT into EbookSources (EbookId, Type, Url)
|
||||
values (?,
|
||||
?,
|
||||
?)
|
||||
', [$source->EbookId, $source->Type, $source->Url]);
|
||||
|
||||
$source->EbookSourceId = Db::GetLastInsertedId();
|
||||
$source->Create();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1656,24 +1639,7 @@ class Ebook{
|
|||
foreach($allContributors as $sortOrder => $contributor){
|
||||
$contributor->EbookId = $this->EbookId;
|
||||
$contributor->SortOrder = $sortOrder;
|
||||
|
||||
Db::Query('
|
||||
INSERT into Contributors (EbookId, Name, UrlName, SortName, WikipediaUrl, MarcRole, FullName,
|
||||
NacoafUrl, SortOrder)
|
||||
values (?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?)
|
||||
', [$contributor->EbookId, $contributor->Name, $contributor->UrlName, $contributor->SortName,
|
||||
$contributor->WikipediaUrl, $contributor->MarcRole, $contributor->FullName,
|
||||
$contributor->NacoafUrl, $contributor->SortOrder]);
|
||||
|
||||
$contributor->ContributorId = Db::GetLastInsertedId();
|
||||
$contributor->Create();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,4 +11,15 @@ class EbookSource{
|
|||
$instance->Url = $url;
|
||||
return $instance;
|
||||
}
|
||||
|
||||
public function Create(): void{
|
||||
Db::Query('
|
||||
INSERT into EbookSources (EbookId, Type, Url)
|
||||
values (?,
|
||||
?,
|
||||
?)
|
||||
', [$this->EbookId, $this->Type, $this->Url]);
|
||||
|
||||
$this->EbookSourceId = Db::GetLastInsertedId();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,4 +23,16 @@ class GitCommit{
|
|||
$instance->Hash = $hash;
|
||||
return $instance;
|
||||
}
|
||||
|
||||
public function Create(): void{
|
||||
Db::Query('
|
||||
INSERT into GitCommits (EbookId, Created, Message, Hash)
|
||||
values (?,
|
||||
?,
|
||||
?,
|
||||
?)
|
||||
', [$this->EbookId, $this->Created, $this->Message, $this->Hash]);
|
||||
|
||||
$this->GitCommitId = Db::GetLastInsertedId();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue