mirror of
https://github.com/standardebooks/web.git
synced 2025-07-12 09:32:24 -04:00
Remove primary key ContributorId
`Ebook` to `Contributor` is one to many, and we don't query by ContributorId. The table already has a SortOrder column, and we use that to order the queries.
This commit is contained in:
parent
1076c9a77d
commit
3f3cf702b2
3 changed files with 4 additions and 9 deletions
|
@ -1,5 +1,4 @@
|
||||||
CREATE TABLE `Contributors` (
|
CREATE TABLE `Contributors` (
|
||||||
`ContributorId` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
|
||||||
`EbookId` int(10) unsigned NOT NULL,
|
`EbookId` int(10) unsigned NOT NULL,
|
||||||
`Name` varchar(255) NOT NULL,
|
`Name` varchar(255) NOT NULL,
|
||||||
`UrlName` varchar(255) NOT NULL,
|
`UrlName` varchar(255) NOT NULL,
|
||||||
|
@ -9,7 +8,6 @@ CREATE TABLE `Contributors` (
|
||||||
`FullName` varchar(255) NULL,
|
`FullName` varchar(255) NULL,
|
||||||
`NacoafUrl` varchar(255) NULL,
|
`NacoafUrl` varchar(255) NULL,
|
||||||
`SortOrder` tinyint(3) unsigned NOT NULL,
|
`SortOrder` tinyint(3) unsigned NOT NULL,
|
||||||
PRIMARY KEY (`ContributorId`),
|
|
||||||
KEY `index1` (`EbookId`),
|
KEY `index1` (`EbookId`),
|
||||||
KEY `index2` (`UrlName`)
|
KEY `index2` (`UrlName`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
|
@ -5,7 +5,6 @@ use Safe\DateTimeImmutable;
|
||||||
use function Safe\preg_match;
|
use function Safe\preg_match;
|
||||||
|
|
||||||
class Contributor{
|
class Contributor{
|
||||||
public ?int $ContributorId = null;
|
|
||||||
public ?int $EbookId = null;
|
public ?int $EbookId = null;
|
||||||
public string $Name;
|
public string $Name;
|
||||||
public string $UrlName;
|
public string $UrlName;
|
||||||
|
@ -136,7 +135,5 @@ class Contributor{
|
||||||
?)
|
?)
|
||||||
', [$this->EbookId, $this->Name, $this->UrlName, $this->SortName, $this->WikipediaUrl, $this->MarcRole, $this->FullName,
|
', [$this->EbookId, $this->Name, $this->UrlName, $this->SortName, $this->WikipediaUrl, $this->MarcRole, $this->FullName,
|
||||||
$this->NacoafUrl, $this->SortOrder]);
|
$this->NacoafUrl, $this->SortOrder]);
|
||||||
|
|
||||||
$this->ContributorId = Db::GetLastInsertedId();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,7 +210,7 @@ class Ebook{
|
||||||
from Contributors
|
from Contributors
|
||||||
where EbookId = ?
|
where EbookId = ?
|
||||||
and MarcRole = ?
|
and MarcRole = ?
|
||||||
order by ContributorId
|
order by SortOrder asc
|
||||||
', [$this->EbookId, 'aut'], Contributor::class);
|
', [$this->EbookId, 'aut'], Contributor::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,7 +227,7 @@ class Ebook{
|
||||||
from Contributors
|
from Contributors
|
||||||
where EbookId = ?
|
where EbookId = ?
|
||||||
and MarcRole = ?
|
and MarcRole = ?
|
||||||
order by ContributorId
|
order by SortOrder asc
|
||||||
', [$this->EbookId, 'ill'], Contributor::class);
|
', [$this->EbookId, 'ill'], Contributor::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ class Ebook{
|
||||||
from Contributors
|
from Contributors
|
||||||
where EbookId = ?
|
where EbookId = ?
|
||||||
and MarcRole = ?
|
and MarcRole = ?
|
||||||
order by ContributorId
|
order by SortOrder asc
|
||||||
', [$this->EbookId, 'trl'], Contributor::class);
|
', [$this->EbookId, 'trl'], Contributor::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ class Ebook{
|
||||||
from Contributors
|
from Contributors
|
||||||
where EbookId = ?
|
where EbookId = ?
|
||||||
and MarcRole = ?
|
and MarcRole = ?
|
||||||
order by ContributorId
|
order by SortOrder asc
|
||||||
', [$this->EbookId, 'ctb'], Contributor::class);
|
', [$this->EbookId, 'ctb'], Contributor::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue