Bonjour,
Le getPrenom() m'orientait vers une fausse piste.
Je reviens de période de congé + examen. Bref, voici ce que j'ai trouvé :
Code : Tout sélectionner
class Utilisateur {
//Attributs privés
private $cp, $id_affectation, $nom, $prenom, $genre, $adresse_email,
$mot_de_passe, $cp_dpx, $fonction, $notification_dpx, $reception_mail, $nb_jours;
private $affectation;
const ADC = 'ADC';
const CTT = 'CTT';
const GM = 'GM';
const ADMIN = 'ADMIN';
const SUPER_ADMIN = 'SUPER_ADMIN';
//Constructeur
public function __construct() {
$this->cp = '';
$this->id_affectation = '';
$this->nom = '';
$this->prenom = '';
$this->genre = '';
$this->adresse_email = '';
$this->mot_de_passe = '';
$this->cp_dpx = '';
$this->fonction = '';
$this->notification_dpx = '';
$this->reception_mail= '';
$this->nb_jours= '';
$this->affectation = new Affectation();
}
Et voici ce qu'il se passe lorsque j'essaye d'ajouter un utilisateur via formulaire :
Code : Tout sélectionner
object(Utilisateur)[5]
private 'cp' => string '0000000A' (length=8)
private 'id_affectation' => string '1' (length=1)
private 'nom' => string 'test' (length=4)
private 'prenom' => string 'test' (length=4)
private 'genre' => string '0' (length=1)
private 'adresse_email' => string '[email protected]' (length=12)
private 'mot_de_passe' => string '008a766e159f3f33b5d991fa072bfd516705ec06' (length=40)
private 'cp_dpx' => string '0000000Z' (length=8)
private 'fonction' => string 'ADC' (length=3)
private 'notification_dpx' => int 0
private 'reception_mail' => string '' (length=0)
private 'nb_jours' => string '' (length=0)
private 'affectation' =>
object(Affectation)[6]
private 'id_affectation' => string '' (length=0)
private 'etablissement' => string '' (length=0)
private 'uo' => string '' (length=0)
private 'residence' => string '' (length=0)
L'objet affectation ne se remplit pas. Il n'arrive pas à récupérer les données du select du formulaire qui sont sous la forme :
Code : Tout sélectionner
<td>Affectation</td>
<select name="id_affectation" required>
<?php foreach ($liste_affectations as $key => $value) : ?>
<option value="<?php echo $value['id_affectation']; ?>">
<?php echo $value['uo'].' - '.$value['residence']; ?></option>
<?php endforeach; ?>
uo et residence sont des champs de la table affectation.
C'est en changeant de méthode et en travaillant en local sur mon pc perso que j'ai découvert que
Néanmoins comment cela ce fait qu'elle m'affiche toutes les affectations possible dans le select ? Car l'id affectation lui est récupéré et est une foreign key de l'id de la table affectation.
Et voici la fonction ajouter():
Code : Tout sélectionner
public function ajouter() {
$BDD = new Memory();
return $BDD->insert('utilisateur', utf8_desarray($this->unserialise()));
}
Dans le contrôleur je serialize
pour ensuite le
dans la fonction ajouter ?
J'ai du mal a comprendre.
ps* : L'application date de 2016, je ne suis pas le créateur.
Bonjour,
Le getPrenom() m'orientait vers une fausse piste.
Je reviens de période de congé + examen. Bref, voici ce que j'ai trouvé :
[code]
class Utilisateur {
//Attributs privés
private $cp, $id_affectation, $nom, $prenom, $genre, $adresse_email,
$mot_de_passe, $cp_dpx, $fonction, $notification_dpx, $reception_mail, $nb_jours;
private $affectation;
const ADC = 'ADC';
const CTT = 'CTT';
const GM = 'GM';
const ADMIN = 'ADMIN';
const SUPER_ADMIN = 'SUPER_ADMIN';
//Constructeur
public function __construct() {
$this->cp = '';
$this->id_affectation = '';
$this->nom = '';
$this->prenom = '';
$this->genre = '';
$this->adresse_email = '';
$this->mot_de_passe = '';
$this->cp_dpx = '';
$this->fonction = '';
$this->notification_dpx = '';
$this->reception_mail= '';
$this->nb_jours= '';
$this->affectation = new Affectation();
}
[/code]
Et voici ce qu'il se passe lorsque j'essaye d'ajouter un utilisateur via formulaire :
[code]
object(Utilisateur)[5]
private 'cp' => string '0000000A' (length=8)
private 'id_affectation' => string '1' (length=1)
private 'nom' => string 'test' (length=4)
private 'prenom' => string 'test' (length=4)
private 'genre' => string '0' (length=1)
private 'adresse_email' => string '
[email protected]' (length=12)
private 'mot_de_passe' => string '008a766e159f3f33b5d991fa072bfd516705ec06' (length=40)
private 'cp_dpx' => string '0000000Z' (length=8)
private 'fonction' => string 'ADC' (length=3)
private 'notification_dpx' => int 0
private 'reception_mail' => string '' (length=0)
private 'nb_jours' => string '' (length=0)
private 'affectation' =>
object(Affectation)[6]
private 'id_affectation' => string '' (length=0)
private 'etablissement' => string '' (length=0)
private 'uo' => string '' (length=0)
private 'residence' => string '' (length=0)
[/code]
L'objet affectation ne se remplit pas. Il n'arrive pas à récupérer les données du select du formulaire qui sont sous la forme :
[code]
<td>Affectation</td>
<select name="id_affectation" required>
<?php foreach ($liste_affectations as $key => $value) : ?>
<option value="<?php echo $value['id_affectation']; ?>">
<?php echo $value['uo'].' - '.$value['residence']; ?></option>
<?php endforeach; ?>
[/code]
uo et residence sont des champs de la table affectation.
C'est en changeant de méthode et en travaillant en local sur mon pc perso que j'ai découvert que
[code]$liste_affectations est undefined[/code]
Néanmoins comment cela ce fait qu'elle m'affiche toutes les affectations possible dans le select ? Car l'id affectation lui est récupéré et est une foreign key de l'id de la table affectation.
Et voici la fonction ajouter():
[code]
public function ajouter() {
$BDD = new Memory();
return $BDD->insert('utilisateur', utf8_desarray($this->unserialise()));
}
[/code]
Dans le contrôleur je serialize [code]$nouvel_utilisateur->serialise($_POST);[/code]
pour ensuite le [code]Unserialize[/code] dans la fonction ajouter ?
J'ai du mal a comprendre.
ps* : L'application date de 2016, je ne suis pas le créateur.