$result=pg_query_params($db,"SELECT COUNT(*) From Trajet WHERE mailproposition = $1 AND $2 BETWEEN datedepart AND datearrivee;",array($mail,$dateDepart));
$result=pg_query_params($db,"SELECT nbplaces FROM Voiture vo, Trajet ta WHERE vo.mail = ta.mailproposition AND ta.codeTrajet = $1 LIMIT 1;",array($codetrajet));
$result2=pg_query_params($db,"SELECT COUNT(*) FROM Reserver re, Trajet ta WHERE re.codetrajet.mail = ta.codetrajet AND ta.codetrajet = $1;",array($codetrajet));
if(!$result||!$result2){
returnfalse;
}
$nbplaces=pg_fetch_array($result);
$nbreservations=pg_fetch_array($result);
return$nbplaces-1>$nbreservations;
}
//Vérifier la cohérence des dates
functioncheckDatesReserve($db,$mail,$dateDepart)
{
$result=pg_query_params($db,"SELECT COUNT(*) From Trajet ta, reserve re WHERE re.mailutilisateur = $1 AND re.codetrajet = ta.codetrajet AND $2 BETWEEN datedepart AND datearrivee;",array($mail,$dateDepart));
$result=pg_query_params($db,"SELECT COUNT(*) from Trajet WHERE mailProposition = $1 AND estAnnule = false AND datedepart >= current_date;",array($mail));
$result=pg_query_params($db,"SELECT COUNT(*) FROM trajet tr, reserver r WHERE r.codetrajet = tr.codetrajet AND mailutilisateur = $1 AND estAnnule = false AND datedepart >= current_date;",array($mail));
$result=pg_query_params($db,"SELECT COUNT(tr.mailProposition) FROM Trajet tr, Avis av WHERE tr.codeTrajet = av.codeTrajet AND av.estLu = false AND tr.mailProposition = $1;",array($mail));
if($result){
$row=pg_fetch_array($result);
$login=$row[0];
return$login;
}
}
//Récupérer la liste des voitures concernant un utilisateur
$result=pg_query_params($db,"SELECT v.nomVille FROM ville v, traverser tr WHERE tr.nomVille = v.nomVille AND tr.codepostal = v.codepostal AND tr.codetrajet = $1 AND tr.numeroetape = (SELECT MIN(numeroetape) FROM traverser WHERE codetrajet = $1);",array($codetajet));
$result=pg_query_params($db,"SELECT v.nomVille FROM ville v, traverser tr WHERE tr.nomVille = v.nomVille AND tr.codepostal = v.codepostal AND tr.codetrajet = $1 AND tr.numeroetape = (SELECT MAX(numeroetape) FROM traverser WHERE codetrajet = $1);",array($codetajet));