Brendan Abolivier 9 лет назад
Родитель
Сommit
b6ff936e60
3 измененных файлов: 7 добавлений и 7 удалений
  1. 4
    5
      web/model/class.categorie.php
  2. 1
    0
      web/model/classes.php
  3. 2
    2
      web/test.php

+ 4
- 5
web/model/class.categorie.php Просмотреть файл

@@ -19,7 +19,7 @@ class Categorie {
19 19
 			)
20 20
 		);
21 21
 
22
-		if(!is_null($this->bdd->Select('*', 'categorie', $options)) {
22
+		if(!is_null($this->bdd->Select('*', 'categorie', $options))) {
23 23
 			$this->nomCat = $nomCat;
24 24
 		} else {
25 25
 			throw new Exception('Catégorie introuvable');
@@ -39,14 +39,13 @@ class Categorie {
39 39
 		}
40 40
 	}
41 41
 
42
-	public static randSelect() {
42
+	public static function randSelect() {
43 43
 		$bdd = new Connector();
44 44
 		$arrayCat = $bdd->Select("*", "categorie");
45
-		$count = $bdd->Select("COUNT(*)", "categorie")[0];
46 45
 		$return = array();
47 46
 		for($i = 0; $i < 2; $i++) {
48
-			$catIndex = rand(0, $count);
49
-			array_push($return, new Categorie($arrayCat[$catIndex-1]['nom_cat']));
47
+			$catIndex = rand(0, sizeof($arrayCat));
48
+			array_push($return, new Categorie($arrayCat[$catIndex]['nom_cat']));
50 49
 		}
51 50
 		return $return;
52 51
 	}

+ 1
- 0
web/model/classes.php Просмотреть файл

@@ -4,3 +4,4 @@
4 4
 require_once('model/class.connector.php');
5 5
 require_once('model/class.question.php');
6 6
 require_once('model/class.questset.php');
7
+require_once('model/class.categorie.php');

+ 2
- 2
web/test.php Просмотреть файл

@@ -5,8 +5,8 @@
5 5
 require_once('model/classes.php');
6 6
 
7 7
 try{
8
-	$questset = new Questset(array("Les CSI", "Les CIR"));
9
-	var_dump($questset);
8
+	$categories = Categorie::randSelect();
9
+	var_dump($categories);
10 10
 }catch(Exception $e) {
11 11
 	echo("<strong>Erreur : </strong>".$e->getMessage());
12 12
 }