Rewrite MultiTableSelect queries with ON

Instead of `USING(EbookId)`, it would be easier to handle
`MultiTableSelect` queries in `FromMultiTableRow()` if the queries used

`ON Projects.EbookId = Ebooks.Ebooks`

This is because `USING` will return only one `EbookId` column, but `ON`
will return all columns from both tables.
This commit is contained in:
Mike Colagrosso 2024-12-31 21:24:58 -07:00 committed by Alex Cabal
parent dad5df0059
commit 0e7bff5d82
3 changed files with 13 additions and 12 deletions

View file

@ -164,8 +164,8 @@ final class Ebook{
SELECT *
from Projects
inner join Ebooks
using(EbookId)
where EbookId = ?
on Projects.EbookId = Ebooks.EbookId
where Ebooks.EbookId = ?
order by Projects.Created desc
', [$this->EbookId], Project::class);
}
@ -183,8 +183,8 @@ final class Ebook{
SELECT *
from Projects
inner join Ebooks
using(EbookId)
where EbookId = ?
on Projects.EbookId = Ebooks.EbookId
where Ebooks.EbookId = ?
and Status in (?, ?)
', [$this->EbookId, Enums\ProjectStatusType::InProgress, Enums\ProjectStatusType::Stalled], Project::class)[0] ?? null;
}
@ -206,8 +206,8 @@ final class Ebook{
SELECT *
from Projects
inner join Ebooks
using(EbookId)
where EbookId = ?
on Projects.EbookId = Ebooks.EbookId
where Ebooks.EbookId = ?
and Status in (?, ?)
', [$this->EbookId, Enums\ProjectStatusType::Completed, Enums\ProjectStatusType::Abandoned], Project::class);
}