Advertisement
nicolas-chuet

modalManager

Apr 3rd, 2020
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. <?php
  2.  
  3. class ModalManager
  4. {
  5. private $mysqli;
  6.  
  7. /**
  8. * ModalManager constructor.
  9. */
  10. public function __construct()
  11. {
  12. // echo "connection\n";
  13. // $mysqli = new mysqli('localhost', 'root', '', 'base_test_modal');
  14. // if (mysqli_connect_errno()) {
  15. // printf("Echec de la connexion: %s\n", mysqli_connect_error());
  16. // exit();
  17. // }
  18. // echo "reussi \n";
  19. }
  20.  
  21. public function insertMysqli(Modal $data)
  22. {
  23. echo "connection\n";
  24. $mysqli = new mysqli('localhost', 'root', '', 'base_test_modal');
  25. if (mysqli_connect_errno()) {
  26. printf("Echec de la connexion: %s\n", mysqli_connect_error());
  27. exit();
  28. }
  29.  
  30.  
  31. echo "reussi \n";
  32. $titre = $data->getTitle();
  33. $texte = $data->getText();
  34. $urls = $data->getUrls();
  35.  
  36. foreach ($urls as $key => $value){
  37.  
  38. $url = $urls[key];
  39. $mysqli->query("INSERT INTO client (`titre`, `texte_modal`)VALUES ($titre, $texte)");
  40.  
  41. }
  42.  
  43. //INSERT INTO `modal`(`id`, `titre`, `texte_modal`) VALUES ([value-1],[value-2],[value-3])
  44. $mysqli->query("INSERT INTO modal (`titre`, `texte_modal`)VALUES ($titre, $texte)");
  45. printf ("Le nouvel enregistrement a l'id %d.\n", $mysqli->insert_id);
  46.  
  47. }
  48.  
  49.  
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement