Guest User

Untitled

a guest
Jul 16th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. <?php
  2. public class dbComponent {
  3. private var $dbhost;
  4. private var $dbname;
  5. private var $dbuser;
  6. private var $dbpass;
  7.  
  8. function __construct($tdbhost,$tdbname,$tdbuser,$tdbpass) {
  9. $this->setDBHost($tdbhost);
  10. $this->setDBName($tdbname);
  11. $this->setDBUser($tdbuser);
  12. $this->setDBPass($tdbpass);
  13.  
  14. $connect = mysql_connect($this->getDBHost(),$this->getDBUser(),$this->getDBPass()) or die(mysql_error());
  15. mysql_select_db($this->getDBName(),$connect);
  16. }
  17.  
  18. public setDBName($name) { // Set database name?
  19. $this->dbname = $name;
  20. }
  21.  
  22. public getDBName() { // Get database name then
  23. return $this->dbname;
  24. }
  25.  
  26. public setDBHost($host) { // Set database host?
  27. $this->dbhost = $host;
  28. }
  29.  
  30. public getDBHost() { // Get database host then
  31. return $this->dbhost;
  32. }
  33.  
  34. public setDBUser($username) { // Set database username?
  35. $this->dbuser = $username;
  36. }
  37.  
  38. public getDBUser() { // Get database username then
  39. return $this->dbuser;
  40. }
  41.  
  42. public setDBPass($password) { // Set database password?
  43. $this->dbpass = $password;
  44. }
  45.  
  46. public getDBPass() { // Get database password then
  47. return $this->dbpass;
  48. }
  49. }
  50. ?>
Add Comment
Please, Sign In to add comment