j'ai une classe candidat
et une classe dossier
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 <?php include "./classes/class_dossier.php"; include "./classes/class_connexion.php"; class candidat extends connexion { private $nom_candidat; private $prenom_candidat; private $dateNaissance; private $pays; private $mesDossiers = array(); private $nbDossiers; public function __construct($login, $mdp, $role, $site, $code_connexion, $nom_candidat, $prenom_candidat, $dateNaissance, $pays) { connexion::__construct($login, $mdp, $role, $site, $code_connexion); $this->nom_candidat = $nom_candidat; $this->prenom_candidat = $prenom_candidat; $this->dateNaissance = $dateNaissance; $this->pays = $pays; $this->nbDossiers = 0; } public function getNbdossier() { return $this->nbDossiers; } //retourne le dossier public function getDossier($indice) { if(isset($this->mesDossiers[$indice])) { return $this->mesDossiers[$indice]; } else { echo "pas dossier"; return NULL; } } public function setDossier($monDossier) { //$this->mesDossiers[] = $monDossier; $this->mesDossiers[$nbDossiers] = $monDossier; $this->nbDossiers++; } }
et voici ce que je fais dans le programme principal
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 class dossier { private $codeDossier; private $dateCreation; private $dateDerniereModif; public function __construct($codeDossier, $dateCreation, $dateDerniereModif) { $this->codeDossier = $codeDossier; $this->dateCreation = $dateCreation; $this->dateDerniereModif = $dateDerniereModif; } public function getCodeDossier() { return $this->codeDossier; } public function getDateCreation() { return $this->dateCreation; } }
La ligne en gras ne fonctionne pas. Voici l'erreur
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79 $allCandidats = mysql_query("SELECT * FROM connexion, candidat, site, dossier, projet, projetpersonnel WHERE connexion.code_connexion = candidat.code_connexion AND dossier.code_connexion = candidat.code_connexion AND site.code_site = connexion.code_site and projet.code_projet = projetpersonnel.code_projet and dossier.code_dossier = projetpersonnel.code_dossier"); $arrayCandidats = array(); $nbElements = 0; while($row = mysql_fetch_array($allCandidats)) { // Création des candidats $candidat = new candidat(NULL, NULL, NULL, $row[2], $row[0], $row[11], $row[12], $row[22], $row[37]); if($nbElements == 0) { $arrayCandidats[$nbElements] = $candidat; $nbElements++; } else { for($i=0; $i<$nbElements; $i++) { if($candidat == $arrayCandidats[$i]) { break; } else { $arrayCandidats[$nbElements] = $candidat; $nbElements++; } } } } //on parcours le tableau d'objets candidats for($j=0; $j<$nbElements; $j++) { // Dossiers exsitants pour le candidat en cours $queryDossier = mysql_query("SELECT dossier.code_dossier, datecreationdossier, DATEDERNIEREMODIFICATIONDOSSIER FROM dossier where code_connexion =".$arrayCandidats[$j]->getCode().""); while($infoDossier = mysql_fetch_array($queryDossier)) { // Création du dossier $dossier = new dossier($infoDossier[0], $infoDossier[1], $infoDossier[2]); echo "R"; //On rempli le tableau des dossiers pour ce candidat $arrayCandidats[$j]->setDossier($dossier); } for($o=0; $o<$arrayCandidats[$j]->getNbdossier(); $o++) { echo "<tr>"; echo "<td>"; echo "<a href=voirDossier.php?codeDossier=".$arrayCandidats[$j]->getDossier($o)->getCodeDossier()."><img src=./images/edit.GIF></a>"; echo "</td>"; echo "<td>"; echo $arrayCandidats[$j]->getNom(); echo "</td>"; echo "<td>"; echo $arrayCandidats[$j]->getPrenom(); echo "</td>"; echo "<td>"; echo $arrayCandidats[$j]->getDossier($o)->getCodeDossier(); echo "</td>"; echo "<td>"; echo $arrayCandidats[$j]->getDossier($o)->getDateCreation(); echo "</td>"; echo "<td>"; echo $arrayCandidats[$j]->getSite(); echo "</td>"; echo "<td>"; echo $arrayCandidats[$j]->getAge(); echo "</td>"; echo "<td>"; echo $arrayCandidats[$j]->getPays(); echo "</td>"; echo "</tr>"; } }
Si quelqu'un voit l'erreur Merci de m'aider
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 Fatal error: Call to a member function getCodeDossier() on a non-object in D:\Mes documents\Developpements\webphp5\Tableau synthese\test.php on line 90
Partager