1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
private function getConnexion()
{
$connexion = new PDO("mysql:host=localhost;dbname=projetphpobjet","root",""); /*connexion à la base de données*/
return $connexion;
}
public function insertionBaseMessage($objetMessage)
{
echo $objetMessage->getPseudo();
echo $objetMessage->getMessage();
$connexion= $this->getConnexion();
$requete = $connexion -> prepare("INSERT INTO TABLE messages (pseudo, commentaireSeul)
VALUES (' ". $objetMessage->getPseudo() ."', '". $objetMessage->getMessage() ."')");
$requete->execute();
} |