You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

108 lines
3.2 KiB

<?php
use App\Enumerators\SessionElement;
use App\Wrappers\DatabaseInteractions;
use App\Wrappers\SessionWrapper;
use App\Wrappers\SQLQueryBuilderWrapper;
use App\Wrappers\TwigWrapper;
require_once __DIR__ . "/../vendor/autoload.php";
$db = new DatabaseInteractions();
$yourTunes = $db->RunSelect(
queryBuilder: SQLQueryBuilderWrapper::SELECT(
table: 'Tunes'
)
->where(cond: 'T.CreatedBy LIKE :__user_id__')
->bindValue(name: '__user_id__', value: SessionWrapper::Get(target: SessionElement::USER_ID))
);
$yourTuneSets = $db->RunSelect(
queryBuilder: SQLQueryBuilderWrapper::SELECT(
table: 'TuneSets'
)
->cols(cols: [
"CONCAT('[',
GROUP_CONCAT(
CONCAT(
'{\"ID\":', JSON_QUOTE(IFNULL(T_T.ID, '')), ',',
'\"CreatedAt\":', JSON_QUOTE(IFNULL(T_TST.CreatedAt, '')), ',',
'\"Title\":', JSON_QUOTE(IFNULL(T_T.Title, '')), ',',
'\"TimesThrough\":', IFNULL(T_TST.TimesThrough, 0), '}'
)
),
']'
) AS TunesInSet"
])
->join(
join: 'LEFT',
spec: 'TuneSetTunes AS T_TST',
cond: 'T.ID=T_TST.TuneSetID'
)
->join(
join: 'LEFT',
spec: 'Tunes AS T_T',
cond: 'T_TST.TuneID=T_T.ID'
)
->where(cond: 'T.CreatedBy LIKE :__user_id__')
->orderBy(spec: [
'T_TST.Order ASC',
])
->bindValue(name: '__user_id__', value: SessionWrapper::Get(target: SessionElement::USER_ID))
);
for($i = 0; $i < sizeof($yourTuneSets); $i++)
$yourTuneSets[$i]["TunesInSet"] = json_decode($yourTuneSets[$i]["TunesInSet"], true);
$yourLikedTunes = $db->RunSelect(
queryBuilder: SQLQueryBuilderWrapper::SELECT(
table: 'TuneRatings'
)
->cols(cols: [
'T_T.Title',
'T_T.CreatedAt',
'T_T.Copyright',
])
->join(
join: 'INNER',
spec: 'Tunes AS T_T',
cond: 'T.TuneID=T_T.ID',
)
->where(cond: 'T.CreatedBy LIKE :__user_id__')
->where(cond: 'Rating = 1')
->bindValue(name: '__user_id__', value: SessionWrapper::Get(target: SessionElement::USER_ID))
);
$yourDislikedTunes = $db->RunSelect(
queryBuilder: SQLQueryBuilderWrapper::SELECT(
table: 'TuneRatings'
)
->cols(cols: [
'T_T.Title',
'T_T.CreatedAt',
'T_T.Copyright',
])
->join(
join: 'INNER',
spec: 'Tunes AS T_T',
cond: 'T.TuneID=T_T.ID',
)
->where(cond: 'T.CreatedBy LIKE :__user_id__')
->where(cond: 'Rating = 0')
->bindValue(name: '__user_id__', value: SessionWrapper::Get(target: SessionElement::USER_ID))
);
TwigWrapper::RenderTwig(
target: "Pages/profile.html.twig",
arguments: [
"YourTunes" => $yourTunes,
"YourTuneSets"=> $yourTuneSets,
"YourLikedTunes"=> $yourLikedTunes,
"YourDislikedTunes"=> $yourDislikedTunes,
"YourBookmarkedTunes"=> [],
"YourDances" => [],
],
);