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.

47 lines
1.9 KiB

<?php
class SqliteDb extends SQLite3
{
function __construct()
{
$this->open('test.db');
//$this->createTable();
}
function createTable(){
//Création De La Table
$this->exec('DROP TABLE Correct');
$this->exec('CREATE TABLE Correct ( question STRING, reponse STRING)');
//Question 1
$test = 'SELECT count(*) FROM stats WHERE prenomnoms=\'Kevin Durant\' ';
$q = "INSERT INTO Correct VALUES ('Trouver le nombre de matchs joués par Kevin Durant', ? )";
$stmt = $this->prepare($q);
$stmt->bindParam(1,$test);
$stmt->execute();
//Question 2
$test = ' SELECT prenomnoms,datematch,points,equipeadverse FROM stats WHERE points = (SELECT max(points) FROM stats)';
$q = "INSERT INTO Correct VALUES ('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,$test);
$stmt->execute();
//Question 3
$test = ' 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 ('Lister le(s) joueur(s) ayant joué le plus de match pendant la saison', ? )";
$stmt = $this->prepare($q);
$stmt->bindParam(1,$test);
$stmt->execute();
//Question 5
$test = 'SELECT * FROM equipe WHERE nom= \'Hawks\' ';
$q = "INSERT INTO Correct VALUES ('Déterminer pour Kevin Durant pour le match du 30-oct-17 quelle est l équipe qui joue à domicile', ? )";
$stmt = $this->prepare($q);
$stmt->bindParam(1,$test);
$stmt->execute();
}
}