bonjour,
j'ai un petit soucis concernant l'appel d'une methode par une autre.
voici mon code :
lors de l'execution du code, j'obtiens une notice correspondant a la ligne d'appel de la func1
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 class MaClasse{ public $getDataSql, $resultSQL, $table; function func2($dbCxn) { $this->getDataSql = " SELECT ch1, ch2 FROM maTable"; $this->resultSQL = $dbCxn->query($this->getDataSql) or trigger_error (E_USER_ERROR); if (count($this->resultSQL) > 0 ) { while ($this->table = $this->resultSQL->fetch(PDO::FETCH_ASSOC) { echo "les resultats sont:".$this->table['ch1']; $this->func1 ($dbCxn, $this->table['ch2']); } } } function func1($dbCxn,$idChamps) { $this->getDataSql = " SELECT ch3 FROM table2 WHERE id ='".$idChamps."'"; $this->resultSQL = $dbCxn->query($this->getDataSql) or trigger_error(E_USER_ERROR); if (count($this->resultSQL) > 0 ) { while ($this->table = $this->resultSQL->fetch(PDO::FETCH_ASSOC) { echo "les resultats sont:".$this->table['ch3']; } } } }
notice:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 $this->func1 ($dbCxn, $this->table['ch2']);
Si quelqu'un pouvait m'expliquer ( en espérant avoir été assez clair dans mes explications )ce que je dois changer, parce que la je ne vois pas trop.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 Fatal Error:Call a member function fetch() on a non-object
Par avance merci pour votre aide , conseils...
A++
Partager