Advertisement
Guest User

Untitled

a guest
Jul 10th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. <?php
  2.  
  3. class PDO_Database_Connection{
  4.  
  5. private $host="account.mysqlhost.com";
  6. private $database="mydatabase";
  7. private $user="myusername";
  8. private $password="my.1.Password";
  9. public $dbh;
  10. public $error;
  11. public $status;
  12.  
  13. public function __construct(/* $args */){
  14. /*
  15. foreach( $args as $key => $value ){
  16.  
  17. $this->$key = $value;
  18.  
  19. }
  20. */
  21.  
  22. try {
  23. $this->dbh = new PDO("mysql:host=foerster.yourwebhostingmysql.com;dbname=$this->database", $this->user, $this->password);
  24. /*** echo a message saying we have connected ***/
  25. //echo 'Connected to database';
  26. $this->status = "connected";
  27. }
  28. catch(PDOException $e)
  29. {
  30. //echo $e->getMessage();
  31. $this->error = $e->getMessage();
  32. }
  33.  
  34. }
  35.  
  36. }
  37. /*
  38. $db = new PDO_Database_Connection();
  39. $dbh = $db->dbh;
  40. echo $db->status;
  41. echo $db->error;
  42. */
  43. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement