$this->exec("INSERT INTO Type VALUES(2,'query')");
$this->exec("INSERT INTO Type VALUES(3,'query')");
$this->exec("INSERT INTO Type VALUES(4,'query')");
$this->exec("INSERT INTO Type VALUES(5,'query')");
$this->exec("INSERT INTO Type VALUES(6,'functionCorrect')");
$this->exec("INSERT INTO Type VALUES(5,'functionCorrect')");
//Question 1
$type = 'query';
$fonctionCorrect = null;
$testU = null;
$points =1;
$reponse = 'SELECT count(*) FROM STATS WHERE prenomnoms=\'Kevin Durant\' ';
$q = "INSERT INTO Correct VALUES (1,'Trouver le nombre de matchs joués par Kevin Durant', ? ,?,?,?)";
$q = "INSERT INTO Correct VALUES (1,'Trouver le nombre de matchs joués par Kevin Durant', ? ,?)";
$stmt = $this->prepare($q);
$stmt->bindParam(1,$reponse);
$stmt->bindParam(2,$type);
$stmt->bindParam(3,$fonctionCorrect);
$stmt->bindParam(4,$testU);
$stmt->bindParam(2,$points);
$stmt->execute();
//Question 2
$type = 'query';
$fonctionCorrect = null;
$testU = null;
$points =1;
$reponse = ' SELECT prenomnoms,datematch,points,equipeadverse FROM STATS WHERE points = (SELECT max(points) FROM STATS)';
$q = "INSERT INTO Correct VALUES (2,'Lister le(s) joueur(s) ayant marqué le plus de points dans la saison en indiquant son nom, la date du match, le nombre de points, l équipe adverse et le nombre de points marqués ', ? ,?,?,?)";
$q = "INSERT INTO Correct VALUES (2,'Lister le(s) joueur(s) ayant marqué le plus de points dans la saison en indiquant son nom, la date du match, le nombre de points, l équipe adverse et le nombre de points marqués ', ? ,?)";
$stmt = $this->prepare($q);
$stmt->bindParam(1,$reponse);
$stmt->bindParam(2,$type);
$stmt->bindParam(3,$fonctionCorrect);
$stmt->bindParam(4,$testU);
$stmt->bindParam(2,$points);
$stmt->execute();
//Question 3
$type = 'query';
$fonctionCorrect = null;
$testU = null;
$points =1;
$reponse = ' SELECT prenomnoms, COUNT(*) FROM STATS GROUP BY prenomnoms HAVING count(*) = (SELECT MAX(c) FROM (SELECT COUNT(*) AS c FROM STATS GROUP BY prenomnoms))';
$q = "INSERT INTO Correct VALUES (3,'Lister le(s) joueur(s) ayant joué le plus de match pendant la saison', ? ,?,?,?)";
$q = "INSERT INTO Correct VALUES (3,'Lister le(s) joueur(s) ayant joué le plus de match pendant la saison', ? ,?)";
$stmt = $this->prepare($q);
$stmt->bindParam(1,$reponse);
$stmt->bindParam(2,$type);
$stmt->bindParam(3,$fonctionCorrect);
$stmt->bindParam(4,$testU);
$stmt->bindParam(2,$points);
$stmt->execute();
//Question 5
//Question 4
$type = 'query';
$fonctionCorrect = null;
$testU = null;
$points =1;
$reponse = 'SELECT nom FROM EQUIPE, STATS WHERE datematch = \'30-OCT-17\' AND prenomnoms = \'Kevin Durant\' AND idequipe = CASE WHEN locationjoueur = \'Away\' THEN equipeadverse WHEN locationjoueur = \'Home\' THEN equipejoueur END ';
$q = "INSERT INTO Correct VALUES (4,'Déterminer pour Kevin Durant pour le match du 30-oct-17 quelle est l équipe qui joue à domicile', ?,?,?,? )";
$q = "INSERT INTO Correct VALUES (4,'Déterminer pour Kevin Durant pour le match du 30-oct-17 quelle est l équipe qui joue à domicile', ?,? )";
$fonctionCorrect = 'CREATE OR REPLACE FUNCTION fpointsmarques(date_match IN VARCHAR2, joueur IN VARCHAR2 ) RETURN NUMBER IS nbPoints NUMBER ; BEGIN SELECT DISTINCT points INTO nbPoints FROM STATS WHERE datematch = date_match AND prenomnoms=joueur; RETURN nbPoints; END;' ;
$fonctionCorrect = 'CREATE OR REPLACE FUNCTION fpointsmarques(date_match IN VARCHAR2, joueur IN VARCHAR2 ) RETURN NUMBER IS nbPoints NUMBER ; BEGIN SELECT points INTO nbPoints FROM STATS WHERE datematch = date_match AND prenomnoms=joueur; RETURN nbPoints; END;' ;
$reponse = 'SELECT fpointsmarques(\''.$dateRandom.'\', \''.$joueurRandom.'\') FROM DUAL';
$testU = 'SELECT pointsmarques(\''.$dateRandom.'\', \''.$joueurRandom.'\') FROM DUAL' ;
$q = "INSERT INTO FunctionCorrect VALUES (5,'Ecrire une fonction pointsmarques qui détermine pour une date de match et un joueur donnés quelle est le nombre de points marqués par ce joueur', ?,?,?,? )";
@ -170,6 +157,20 @@ class SqliteDb extends SQLite3