Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/master'

PCYoshi 9 gadus atpakaļ
vecāks
revīzija
c22a6dd945
6 mainītis faili ar 55 papildinājumiem un 97 dzēšanām
  1. 0
    0
      sql/CTITbq.sql
  2. 9
    4
      sql/ITbq.sql
  3. 0
    92
      sql/burgerquizzSTRUCT.sql
  4. 9
    0
      web/class.connector.php
  5. 32
    0
      web/class.questset.php
  6. 5
    1
      web/palmares.php

sql/burgerquizzDATAandSTRUCT.sql → sql/CTITbq.sql Parādīt failu


sql/burgerquizzDATA.sql → sql/ITbq.sql Parādīt failu

@@ -70,11 +70,16 @@ INSERT INTO `reponses` (`reponse1`, `reponse2`, `nom_cat`) VALUES
70 70
 --
71 71
 
72 72
 INSERT INTO `scores` (`login`, `score`) VALUES
73
-('Jean', 85),
74
-('kikou37', 14),
75
-('Micheline', 85),
73
+('azerty', 28),
74
+('David', 19),
75
+('Dragavnir', 666),
76
+('Finistère', 29),
77
+('Joseph', 42),
78
+('K.S.', 20),
79
+('Loic', 10),
80
+('Marc F.', 0),
76 81
 ('Patrick', 24),
77
-('thefifou', 56);
82
+('Thomas', 33);
78 83
 
79 84
 /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
80 85
 /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;

+ 0
- 92
sql/burgerquizzSTRUCT.sql Parādīt failu

@@ -1,116 +0,0 @@
1
---
2
-
3
-SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
4
-SET time_zone = "+00:00";
5
-
6
-
7
-/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
8
-/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
9
-/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
10
-/*!40101 SET NAMES utf8 */;
11
-
12
---
13
---
14
-
15
-
16
---
17
---
18
-
19
-CREATE TABLE IF NOT EXISTS `categorie` (
20
-  `nom_cat` varchar(30) NOT NULL
21
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
22
-
23
-
24
---
25
---
26
-
27
-CREATE TABLE IF NOT EXISTS `questions` (
28
-  `intitule` varchar(150) NOT NULL,
29
-  `num_reponse` tinyint(4) NOT NULL,
30
-  `reponse1` varchar(50) NOT NULL DEFAULT '',
31
-  `reponse2` varchar(50) NOT NULL DEFAULT ''
32
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
33
-
34
-
35
---
36
---
37
-
38
-CREATE TABLE IF NOT EXISTS `reponses` (
39
-  `reponse1` varchar(50) NOT NULL,
40
-  `reponse2` varchar(50) NOT NULL,
41
-  `nom_cat` varchar(30) NOT NULL
42
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
43
-
44
-
45
---
46
---
47
-
48
-CREATE TABLE IF NOT EXISTS `scores` (
49
-  `login` varchar(20) NOT NULL,
50
-  `score` int(11) NOT NULL
51
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
52
-
53
---
54
---
55
-
56
---
57
---
58
-ALTER TABLE `categorie`
59
- ADD PRIMARY KEY (`nom_cat`);
60
-
61
---
62
---
63
-ALTER TABLE `questions`
64
- ADD PRIMARY KEY (`intitule`,`reponse1`,`reponse2`), ADD KEY `FK_Questions_reponse2` (`reponse2`), ADD KEY `FK_Questions_reponse1` (`reponse1`);
65
-
66
---
67
---
68
-ALTER TABLE `reponses`
69
- ADD PRIMARY KEY (`reponse1`,`reponse2`), ADD KEY `reponse2` (`reponse2`), ADD KEY `FK_Reponses_nom_cat` (`nom_cat`);
70
-
71
---
72
---
73
-ALTER TABLE `scores`
74
- ADD PRIMARY KEY (`login`);
75
-
76
---
77
---
78
-
79
---
80
---
81
-ALTER TABLE `questions`
82
-ADD CONSTRAINT `FK_Questions_reponse1` FOREIGN KEY (`reponse1`) REFERENCES `reponses` (`reponse1`) ON DELETE CASCADE ON UPDATE CASCADE,
83
-ADD CONSTRAINT `FK_Questions_reponse2` FOREIGN KEY (`reponse2`) REFERENCES `reponses` (`reponse2`) ON DELETE CASCADE ON UPDATE CASCADE;
84
-
85
---
86
---
87
-ALTER TABLE `reponses`
88
-ADD CONSTRAINT `FK_Reponses_nom_cat` FOREIGN KEY (`nom_cat`) REFERENCES `categorie` (`nom_cat`) ON DELETE CASCADE ON UPDATE CASCADE;
89
-
90
-/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
91
-/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
92
-/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

+ 9
- 0
web/class.connector.php Parādīt failu

@@ -11,6 +11,7 @@ class Connector {
11 11
 		$pass = "chabat";
12 12
 
13 13
 		$this->bdd = new PDO("mysql:host=$host;dbname=$db", $user, $pass);
14
+		$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
14 15
 	}
15 16
 
16 17
 	/*
@@ -76,4 +77,12 @@ class Connector {
76 77
 			return null;
77 78
 		}
78 79
 	}
80
+
81
+	function beginTransaction() {
82
+		$this->bdd->beginTransaction();
83
+	}
84
+
85
+	function commit() {
86
+		$this->bdd->commit();
87
+	}
79 88
 }

+ 32
- 0
web/class.questset.php Parādīt failu

@@ -0,0 +1,32 @@
1
+<?php
2
+
3
+class Questset {
4
+	private $categorie;
5
+	private $reponse1;
6
+	private $reponse2;
7
+	private $intitules;
8
+	private $bdd;
9
+
10
+	function __construct($reponses) {
11
+		if(is_array($reponses)) {
12
+			$this->reponse1 = $reponse[0];
13
+			$this->reponse2 = $reponse[1];
14
+			try {
15
+				$this->bdd = new Connector();
16
+
17
+				$options = array(
18
+					"where" => array(
19
+						array("reponse1", "=", $reponse1),
20
+						array("reponse2", "=", $reponse2)
21
+					)
22
+				);
23
+
24
+
25
+			} catch(Exception $e) {
26
+				throw $e;
27
+			}
28
+		} else {
29
+			throw new Exception('Un tableau de réponses est attendu dans le constructeur.');
30
+		}
31
+	}
32
+}

+ 5
- 1
web/palmares.php Parādīt failu

@@ -9,7 +9,11 @@ $options = array(
9 9
 	"limit" => array(0, 10) // Ou array(10)
10 10
 );
11 11
 
12
-$res = $bdd->Select("*", "scores", $options);
12
+try {
13
+	$res = $bdd->Select("*", "scores", $options);
14
+} catch(Exception $e) {
15
+	echo("Erreur : ".$e->getMessage());
16
+}
13 17
 
14 18
 echo("<ol>");
15 19