Pourquoi le constructeur de la classe ci-dessous, qui fonctionne correctement en php 7.4, ne fonctionne-t-il plus en php 8 ?
class monoTable
{
public $tbPrincipal;
public $tbMono;
public $champNum;
public $champAlpha;
public $champClePrincipale;
public $champAlphaPrincipal;
public function monoTable ($tablePrincipale,$tableMono)
{
$this->tbPrincipal = $tablePrincipale;
$this->tbMono = $tableMono;
$res = requete ("SELECT * FROM $tableMono");
$this->champNum = $res->fetch_field_direct (0)->name;
$this->champAlpha = $res->fetch_field_direct (1)->name;
$res = requete ("SELECT * FROM $this->tbPrincipal");
$this->champClePrincipale = $res->fetch_field_direct (0)->name;
$this->champAlphaPrincipal = $res->fetch_field_direct (1)->name;
}
}
la fonction requete :
function requete ($sql)
{
global $mysqli;
if (!$res = $mysqli->query ($sql))
{
echo "<p>";
echo $mysqli->error;
exit;
}
return $res;
}
après appel à connection à la base de données.
Toutes les variables sont vides !!
Merci de vous pencher sur ce surprenant problème !!
class monoTable
{
public $tbPrincipal;
public $tbMono;
public $champNum;
public $champAlpha;
public $champClePrincipale;
public $champAlphaPrincipal;
public function monoTable ($tablePrincipale,$tableMono)
{
$this->tbPrincipal = $tablePrincipale;
$this->tbMono = $tableMono;
$res = requete ("SELECT * FROM $tableMono");
$this->champNum = $res->fetch_field_direct (0)->name;
$this->champAlpha = $res->fetch_field_direct (1)->name;
$res = requete ("SELECT * FROM $this->tbPrincipal");
$this->champClePrincipale = $res->fetch_field_direct (0)->name;
$this->champAlphaPrincipal = $res->fetch_field_direct (1)->name;
}
}
la fonction requete :
function requete ($sql)
{
global $mysqli;
if (!$res = $mysqli->query ($sql))
{
echo "<p>";
echo $mysqli->error;
exit;
}
return $res;
}
après appel à connection à la base de données.
Toutes les variables sont vides !!
Merci de vous pencher sur ce surprenant problème !!