1 changed files with 45 additions and 16 deletions
@ -1,35 +1,64 @@ |
|||
<?php |
|||
|
|||
use App\Dataclasses\DatabaseFolkTuneDetails; |
|||
use App\Dataclasses\TuneVariant; |
|||
use App\Wrappers\DatabaseInteractions; |
|||
use App\Wrappers\SQLQueryBuilderWrapper; |
|||
|
|||
$tuneDir = __DIR__ . '/../../../LocalStorage/Tunes'; |
|||
$targetTuneID = $_GET['tune-id']; |
|||
|
|||
$db = new DatabaseInteractions(); |
|||
|
|||
$result = (new DatabaseInteractions())->RunOneSelect( |
|||
$tuneDetails = (new DatabaseInteractions())->RunOneSelect( |
|||
queryBuilder: SQLQueryBuilderWrapper::SELECT_ONE( |
|||
table: 'Tunes', |
|||
id: $targetTuneID |
|||
) |
|||
->cols(cols: [ |
|||
'T.*', |
|||
]) |
|||
->cols(cols: [ |
|||
'T.*', |
|||
]) |
|||
); |
|||
|
|||
$temp = new \App\Dataclasses\ABCWrapper($result); |
|||
$variants = $db->RunOneSelect( |
|||
queryBuilder: SQLQueryBuilderWrapper::SELECT( |
|||
table: 'Tunes' |
|||
) |
|||
->cols([ |
|||
'T.ID AS TuneID', |
|||
'T_TV.ID AS TuneVariantID', |
|||
'T.Title', |
|||
"CONCAT('[', GROUP_CONCAT( |
|||
CONCAT( |
|||
'{\"TimeSignature\":', JSON_QUOTE(T_TVP.TimeSignature), ',', |
|||
'\"KeySignature\":', JSON_QUOTE(T_TVP.KeySignature), ',', |
|||
'\"ABCNotation\":', JSON_QUOTE(T_TVP.ABCNotation), '}' |
|||
) |
|||
), ']') AS Parts" |
|||
]) |
|||
->join( |
|||
join: 'INNER', |
|||
spec: 'TuneVariants T_TV', |
|||
cond: 'T.ID = T_TV.TuneID' |
|||
) |
|||
->join( |
|||
join: 'INNER', |
|||
spec: 'TuneVariantParts T_TVP', |
|||
cond: 'T_TV.ID = T_TVP.TuneVariantID' |
|||
) |
|||
->where(cond: 'T.ID = :__tune_id__') |
|||
->groupBy(spec: [ |
|||
'T.ID', |
|||
'T_TV.ID', |
|||
'T.Title', |
|||
]) |
|||
->bindValue(name: '__tune_id__', value: $targetTuneID) |
|||
); |
|||
|
|||
/* |
|||
header(header: "Content-type: text/text"); |
|||
echo($temp->Build()); |
|||
die(); |
|||
*/ |
|||
$tuneDetails = new DatabaseFolkTuneDetails($tuneDetails); |
|||
$tuneDetails->Variants[] = new TuneVariant($tuneDetails, $variants); |
|||
|
|||
/* |
|||
$filePath = "$tuneDir/$targetTuneID/primary.abc"; |
|||
$temp = file_get_contents(filename: $filePath); |
|||
*/ |
|||
|
|||
header(header: "Content-type: text/xml"); |
|||
echo $temp->Build(); |
|||
header(header: "Content-type: text/text"); |
|||
echo $tuneDetails->Variants[0]->Build(); |
|||
die(); |
|||
|
Loading…
Reference in new issue