Guest User

Untitled

a guest
Dec 8th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. <?php
  2.  
  3. class mysql {
  4.  
  5. # MySql Server
  6. private $host = '';
  7. # MySql Benutzername
  8. private $user = '';
  9. # MySql Passwort
  10. private $pass = '';
  11. # MySql Datenbank
  12. private $base = '';
  13.  
  14. # Verbindung herstellen
  15. public function __construct($host, $user, $pass, $base) {
  16.  
  17. # MySql Server
  18. $this->_host = trim($host);
  19. # MySql Benutzername
  20. $this->_user = trim($user);
  21. # MySql Passwort
  22. $this->_pass = trim($pass);
  23. # MySql Datenbank
  24. $this->_base = trim($base);
  25.  
  26. # Verbinden ...
  27. $this->_connection();
  28. }
  29.  
  30. public function _connection() {
  31.  
  32. $con = @mysql_connect($this->_host, $this->_user, $this->_pass);
  33. $db = @mysql_select_db($this->_base, $con);
  34. $this->_db = $db;
  35.  
  36. self::_checkbase();
  37. }
  38.  
  39. public function _checksql($sql) {
  40.  
  41. if($sql == true) {
  42. $this->_sqlerror = '';
  43. }
  44. else
  45. {
  46. $this->_sqlerror = 'Sie haben einen Fehler in einer Query! <br />'.mysql_error().__LINE__;
  47. }
  48.  
  49. }
  50.  
  51.  
  52. public function _checkbase() {
  53.  
  54. if($this->_db == true) {
  55. $this->_error = '';
  56. }
  57. else
  58. {
  59. $this->_error = 'Fehler in der Verbindung!';
  60. }
  61.  
  62. }
  63.  
  64.  
  65. public function assoc($sqlcode = '') {
  66.  
  67. if($sqlcode != '') {
  68. self::_checksql($sqlcode);
  69. return mysql_fetch_assoc($sqlcode);
  70. }
  71. else
  72. {
  73. return '';
  74. }
  75.  
  76. }
  77.  
  78. public function query($query) {
  79.  
  80. self::_checksql($query);
  81. return mysql_query($query);
  82.  
  83. }
  84.  
  85. public function char($string) {
  86.  
  87. return mysql_real_escape_string($string);
  88.  
  89. }
  90.  
  91. public function close_connect() {
  92.  
  93. if ( $this->db == true ) {
  94.  
  95. return @mysql_close($this->db);
  96.  
  97. }
  98.  
  99. }
  100.  
  101. public function __destruct() {
  102.  
  103.  
  104.  
  105. }
  106. }
  107.  
  108. ?>
Add Comment
Please, Sign In to add comment