j'ai un petit soucis pour accéder a une méthode depuis une autre.
j'ai dans une classe , une méthode qui me permets d'afficher par exemple un titre, et je voudrais a la suite de ce titre appeler une autre méthode de la même classe...mais malheureusement ca ne marche pas.
voici mon code :
Code : Tout sélectionner
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'];
}
}
}
}
Code : Tout sélectionner
$this->func1 ($dbCxn, $this->table['ch2']);Code : Tout sélectionner
Fatal Error:Call a member function fetch() on a non-object
Par avance merci pour votre aide