value]) { header("Location: /login"); die(); } $db = new DatabaseInteractions(); $yourTunes = $db->RunSelect( queryBuilder: SQLQueryBuilderWrapper::SELECT( table: 'Tunes' ) ->where(cond: 'T.CreatedBy LIKE :__user_id__') ->orderBy(spec: [ 'T.Title ASC', ]) ->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: 'INNER', spec: 'TuneSetTunes AS T_TST', cond: 'T.ID=T_TST.TuneSetID' ) ->join( join: 'INNER', spec: 'Tunes AS T_T', cond: 'T_TST.TuneID=T_T.ID' ) ->where(cond: 'T.CreatedBy LIKE :__user_id__') ->groupBy(spec: [ 'T.ID', ]) ->orderBy(spec: [ 'T_TST.Order ASC', ]) ->bindValue(name: '__user_id__', value: SessionWrapper::Get(target: SessionElement::USER_ID)) ); for($i = 0, $iMax = count($yourTuneSets); $i < $iMax; $i++) { $yourTuneSets[$i]["TunesInSet"] = json_decode($yourTuneSets[$i]["TunesInSet"], true, 512, JSON_THROW_ON_ERROR); } $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" => [], ], );