Advertisement
Guest User

Untitled

a guest
Dec 24th, 2016
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. <?php
  2. interface Conn
  3. {
  4. public function GetConn();
  5. public function GetConfiguration();
  6. }
  7. class Config implements Conn
  8. {
  9. private $host = 'localhost';
  10. private $user = 'root';
  11. private $pass = 'hcoins';
  12. private $db = 'hcoins';
  13. private $dns = 'mysql';
  14. public $Authorize = 1;
  15. protected $conn;
  16.  
  17. public function GetConn()
  18. {
  19. if($this->Authorize == 1)
  20. {
  21. try
  22. {
  23. $this->conn = new PDO(''.$this->dns.':host='.$this->host.';dbname='.$this->db,$this->user,$this->pass);
  24. $this->conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
  25. $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  26. return $this->conn;
  27. }
  28. catch(PDOException $exception)
  29. {
  30. $e = $exception->getMessage();
  31. echo $e;
  32. }
  33. }
  34. else
  35. {
  36. return print 'Nessun autorizzazione di connessione';
  37. }
  38. }
  39. public function GetConfiguration()
  40. {
  41. if(!file_exists('conn.php'))
  42. {
  43. return print 'File di configurazione globale non trovato';
  44. }
  45. if(!class_exists('Config'))
  46. {
  47. return print 'Classe di configurazione globale non trovata';
  48. }
  49. }
  50. public function GetAll()
  51. {
  52. $function1 = $this->GetConfiguration();
  53. $function2 = $this->GetConn();
  54. return $function1;
  55. return $function2;
  56. }
  57. }
  58.  
  59. $conn = new Config;
  60. $conn->GetAll();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement