Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class ModalManager
- {
- private $mysqli;
- /**
- * ModalManager constructor.
- */
- public function __construct()
- {
- // echo "connection\n";
- // $mysqli = new mysqli('localhost', 'root', '', 'base_test_modal');
- // if (mysqli_connect_errno()) {
- // printf("Echec de la connexion: %s\n", mysqli_connect_error());
- // exit();
- // }
- // echo "reussi \n";
- }
- public function insertMysqli(Modal $data)
- {
- echo "connection\n";
- $mysqli = new mysqli('localhost', 'root', '', 'base_test_modal');
- if (mysqli_connect_errno()) {
- printf("Echec de la connexion: %s\n", mysqli_connect_error());
- exit();
- }
- echo "reussi \n";
- $titre = $data->getTitle();
- $texte = $data->getText();
- $urls = $data->getUrls();
- foreach ($urls as $key => $value){
- $url = $urls[key];
- $mysqli->query("INSERT INTO client (`titre`, `texte_modal`)VALUES ($titre, $texte)");
- }
- //INSERT INTO `modal`(`id`, `titre`, `texte_modal`) VALUES ([value-1],[value-2],[value-3])
- $mysqli->query("INSERT INTO modal (`titre`, `texte_modal`)VALUES ($titre, $texte)");
- printf ("Le nouvel enregistrement a l'id %d.\n", $mysqli->insert_id);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement