Advertisement
Guest User

Untitled

a guest
Oct 16th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. <?php
  2. class JoueurDonnees
  3. {
  4. private $donnees;
  5. private $bdd;
  6. private $reseaux;
  7.  
  8. public function __construct($bdd, $pseudo)
  9. {
  10. $this->bdd = $bdd;
  11. $req = $bdd->prepare('SELECT * FROM cmw_users WHERE pseudo = :pseudo');
  12. $req->execute(Array ( 'pseudo' => $pseudo ));
  13. $donnees = $req->fetch(PDO::FETCH_ASSOC);
  14. $this->donnees = $donnees;
  15. $this->listReseaux();
  16. $this->getReseaux($donnees['id']);
  17. }
  18.  
  19. public function getTableauDonnees(&$reseaux)
  20. {
  21. $reseaux = $this->reseaux;
  22. return $this->donnees;
  23. }
  24.  
  25. private function getReseaux($id)
  26. {
  27. $req = $this->bdd->prepare('SELECT * FROM cmw_reseaux WHERE idJoueur = :id');
  28. $req->execute(array(
  29. 'id' => $id
  30. ));
  31. $data = $req->fetch(PDO::FETCH_ASSOC);
  32. foreach($this->reseaux as $value)
  33. {
  34. if(empty($data[$value['nom']]))
  35. $this->donnees[$value['nom']] = "inconnu";
  36. else
  37. $this->donnees[$value['nom']] = $data[$value['nom']];
  38. }
  39. }
  40.  
  41. private function listReseaux()
  42. {
  43. global $_Serveur_;
  44. $req = $this->bdd->query('SELECT COLUMN_NAME AS nom FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = "cmw_reseaux" AND TABLE_SCHEMA = "'.$_Serveur_['DataBase']['dbName'].'"');
  45. $donneesSocial = $req->fetchAll(PDO::FETCH_ASSOC);
  46. unset($donneesSocial[array_search('id', array_column($donneesSocial, 'nom'))]);
  47. array_merge($donneesSocial);
  48. unset($donneesSocial[array_search('idJoueur', array_column($donneesSocial, 'nom'))+1]);
  49. array_merge($donneesSocial);
  50. $this->reseaux = $donneesSocial;
  51. }
  52. }
  53. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement