Guest User

Untitled

a guest
Sep 21st, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. <?php
  2.  
  3. class DB{
  4. public static $host;
  5. public static $user;
  6. public static $password;
  7. public static $database;
  8. public static $link;
  9.  
  10. public static function DBInsert($arg){
  11. $link = DB::DBlink();
  12. $res = mysqli_query($link, $arg) or die(mysqli_error($link));
  13. }
  14.  
  15. public static function DBlink(){
  16. self::$host = "localhost";
  17. self::$user = "root";
  18. self::$password = "";
  19. self::$database = "cdlcrypto";
  20. self::$link = "";
  21. $link = mysqli_connect(self::$host, self::$user, self::$password, self::$database);
  22. if (isset($link) == 0) {
  23. echo "Unable to connect to MySQL." . PHP_EOL;
  24. echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
  25. exit;
  26. }
  27. return $link;
  28. }
  29. public static function SQLFETCH($sql)
  30. {
  31. $link = DB::DBlink();
  32. $res = mysqli_query($link, $sql) or die(mysqli_error($link));
  33. $result = [];
  34. if (isset($res)) {
  35. while ($item = $res->fetch_object()) {
  36. $result[] = $item;
  37. }
  38. return $result;
  39. } else {
  40. return "DB IS EMPTY";
  41. }
  42. }
  43. public function DBclearquery($sql)
  44. {
  45. $link = DB::DBlink();
  46. $res = mysqli_query($link, $sql) or die(mysqli_error($link));
  47. }
  48. }
  49.  
  50. var_dump(DB::DBlink());
Add Comment
Please, Sign In to add comment