Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. class DataConnection
  2. {
  3. private $host = 'localhost';
  4. private $user = 'genny';
  5. private $pass = 'genny';
  6. private $dbname = 'progetto';
  7.  
  8. private $dbh;
  9. private $error;
  10.  
  11. public function __construct()
  12. {
  13. // Set DSN
  14. $dsn = 'mysql:host=' . $this->host . ';dbname=' . $this->dbname;
  15. // Set options
  16. $options = array(
  17. PDO::ATTR_PERSISTENT => true,
  18. PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
  19. );
  20. // Create a new PDO instanace
  21. try {
  22. $this->dbh = new PDO($dsn, $this->user, $this->pass, $options);
  23. } // Catch any errors
  24. catch (PDOException $e) {
  25. $this->error = $e->getMessage();
  26. }
  27. }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement