public function add(Personnage $perso)
 {
     $q = $this->_db->prepare('INSERT INTO personnages SET nom = :nom');
     $q->bindValue(':nom', $perso->getNom());
     $q->execute();
     $perso->hydrate(["id" => $this->_db->lastInsertId(), "degats" => 0]);
 }
 public function add(Personnage $perso)
 {
     $q = $this->db->prepare('INSERT INTO personnages_v2 SET nom= :nom, type = :type');
     $q->bindValue(':nom', $perso->nom());
     $q->bindValue(':type', $perso->type());
     $q->execute();
     $perso->hydrate(['id' => $this->db->lastInsertId(), 'degats' => 0, 'atout' => 0]);
 }
 public function ajouterPersonnage(Personnage $perso)
 {
     $req = $this->db()->prepare('INSERT INTO Personnage(nom) VALUES(:nom);');
     //$req->bindValue(':id', $perso->id(), PDO::PARAM_INT);
     $req->bindValue(':nom', $perso->nom(), PDO::PARAM_STR);
     //$req->bindValue(':degats',$perso->degats(), PDO::PARAM_INT);
     $req->execute();
     $perso->hydrate(['id' => $this->db()->lastInsertId(), 'degats' => 0]);
 }
 public function add(Personnage $perso)
 {
     // Préparation de la requête d'insertion.
     $q = $this->_db->prepare('INSERT INTO personnages SET nom = :nom');
     // Assignation des valeurs pour le nom du personnage.
     $q->bindValue(':nom', $perso->nom());
     // Exécution de la requête.
     $q->execute();
     // Hydratation du personnage passé en paramètre avec assignation de son identifiant et des dégâts initiaux (=0).
     $perso->hydrate(['id' => $this->_db->lastInsertId(), 'degats' => 0]);
 }
 public function addPersonnage(Personnage $perso)
 {
     $req = $this->bdd->prepare('INSERT INTO Personnages_v2
                                          SET nom    = :nom,
                                              type   = :type
                                ');
     // prepare INSERT request
     $req->bindValue(':nom', $perso->getNom(), PDO::PARAM_STR);
     // Assign Value Personnage
     $req->bindValue(':type', $perso->getType(), PDO::PARAM_STR);
     // Assign Value Type
     $req->execute();
     // execute request
     // hydrate personnage with id and degats - initial = 0
     $perso->hydrate(['id' => $this->bdd->lastInsertId(), 'degats' => 0, 'atout' => 0]);
     $req->closeCursor();
     // close request
 }