Guest User

Untitled

a guest
Feb 9th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. <?php
  2. // class gemaakt door Kevin van Leeuwen
  3. class dbConfig
  4. {
  5. protected $host = false;
  6. protected $username = false;
  7. protected $password = false;
  8.  
  9. public function __construct($host, $username, $password)
  10. {
  11. $this->host = $host;
  12. $this->username = $username;
  13. $this->password = $password;
  14. }
  15.  
  16. public function getHost()
  17. {
  18. return $this->host;
  19. }
  20.  
  21. public function getUsername()
  22. {
  23. return $this->username;
  24. }
  25.  
  26. public function getPassword()
  27. {
  28. return $this->password;
  29. }
  30.  
  31. function __destruct()
  32. {
  33. #destruction!
  34. }
  35. }
  36. abstract class dbConnect
  37. {
  38. public $dbConfig;
  39.  
  40. public function __construct($dbConfig)
  41. {
  42. $this->dbConfig = $dbConfig;
  43. }
  44.  
  45. }
  46. class dbConnectMySQL extends dbConnect
  47. {
  48. public $database;
  49. public $startQuery;
  50. public $getResults;
  51.  
  52.  
  53. public function openConnection()
  54. {
  55. try
  56. {
  57. $this->dbConnect = mysql_connect($this->host, $this->username, $this->password);
  58. $this->dbConnect = mysql_select_db($this->database);
  59. }
  60. catch (Exception $e)
  61. {
  62. return $e;
  63. }
  64. }
  65.  
  66. public function startQuery($query)
  67. {
  68. try
  69. {
  70. if(empty($this->openConnection))
  71. {
  72. $this->openConnection();
  73.  
  74. $this->startQuery = mysql_query($query);
  75.  
  76. return $this->startQuery;
  77. }
  78. else
  79. {
  80.  
  81. $this->startQuery = mysql_query($query);
  82.  
  83. return $this->startQuery;
  84. }
  85. }
  86. catch (Exception $e)
  87. {
  88. return $e;
  89. }
  90. }
  91.  
  92. public function getResults()
  93. {
  94. try
  95. {
  96. return mysql_fetch_assoc($result);
  97. }
  98. catch (Exception $e)
  99. {
  100. return $e;
  101. }
  102. }
  103.  
  104. public function __destruct()
  105. {
  106. //destruction
  107. }
  108. }
  109. ?>
Add Comment
Please, Sign In to add comment