<?php
################################
# SQL FUNCTIONS
################################
function getCategoryPlayerLinks($strPeriodCategories, $playerId)
{
	if ($strPeriodCategories == "ALL")
		return main_db_query("SELECT QCategoryPlayerLinks.CategoryId AS CategoryId, QCategoryPlayerLinks.MeilleurScore AS MeilleurScore, QCategories.Name AS CategoryName, Periods.Name AS PeriodName ".
			" ,Periods.ShowTime AS ShowTime, Periods.EndTime AS EndTime ".
			" FROM QCategoryPlayerLinks ".
			" LEFT JOIN QCategories ON QCategoryPlayerLinks.CategoryId=QCategories.CategoryId ".
			" LEFT JOIN Periods ON Periods.Id=QCategories.PeriodId ".
			" WHERE PlayerId='".$playerId."' ORDER BY Periods.Id DESC");
	else
		return main_db_query("SELECT * FROM QCategoryPlayerLinks WHERE PlayerId='".$playerId."' AND CategoryId IN (".$strPeriodCategories.")");
}

################################

################################
# OPTIM FUNCTIONS
################################

function getQPlayerPeriodCategories($playerId, $strPeriodCategories, &$tabPQuiz)
{
	$rows = getCategoryPlayerLinks($strPeriodCategories, $playerId);
	
	# on retourne un tableau indexé par categoryId
	while($row = db_fetch_array($rows))
	{
		$tabPQuiz[$row['CategoryId']] = $row;
	}
}


################################

