|
@@ -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
|
}
|