Brendan Abolivier 9 years ago
parent
commit
b6ff936e60
3 changed files with 7 additions and 7 deletions
  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 View File

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
 			$this->nomCat = $nomCat;
23
 			$this->nomCat = $nomCat;
24
 		} else {
24
 		} else {
25
 			throw new Exception('Catégorie introuvable');
25
 			throw new Exception('Catégorie introuvable');
39
 		}
39
 		}
40
 	}
40
 	}
41
 
41
 
42
-	public static randSelect() {
42
+	public static function randSelect() {
43
 		$bdd = new Connector();
43
 		$bdd = new Connector();
44
 		$arrayCat = $bdd->Select("*", "categorie");
44
 		$arrayCat = $bdd->Select("*", "categorie");
45
-		$count = $bdd->Select("COUNT(*)", "categorie")[0];
46
 		$return = array();
45
 		$return = array();
47
 		for($i = 0; $i < 2; $i++) {
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
 		return $return;
50
 		return $return;
52
 	}
51
 	}

+ 1
- 0
web/model/classes.php View File

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

+ 2
- 2
web/test.php View File

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