Advertisement
Guest User

Untitled

a guest
Feb 15th, 2021
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP7 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 4.1.0.1
  8. * @ Author : DeZender
  9. * @ Release on : 29.08.2020
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. class Database
  15. {
  16. private $con;
  17. private $error = '';
  18. private $shouldLogQueries = false;
  19. private $queryLogFile = '';
  20. private $lastExecutedStatement;
  21.  
  22. public function __construct($server = '', $user = '', $pass = '', $dbname = '', $new_connection = false)
  23. {
  24. if (($server == '') && ($user == '') && ($pass == '') && ($dbname == '')) {
  25. $server = CONF_DB_SERVER;
  26. $user = CONF_DB_USER;
  27. $pass = CONF_DB_PASS;
  28. $dbname = CONF_DB_NAME;
  29. }
  30.  
  31. if ($new_connection) {
  32. $this->con = new mysqli($server, $user, $pass, $dbname);
  33. $now = new DateTime();
  34. $mins = $now->getOffset() / 60;
  35. $sgn = ($mins < 0 ? -1 : 1);
  36. $mins = abs($mins);
  37. $hrs = floor($mins / 60);
  38. $mins -= $hrs * 60;
  39. $offset = sprintf('%+d:%02d', $hrs * $sgn, $mins);
  40. $this->con->query('SET time_zone=\'' . $offset . '\';');
  41. }
  42. else {
  43. $this->con = SingletonMysqli::getInstance($server, $user, $pass, $dbname);
  44. }
  45.  
  46. if ($this->con->connect_error) {
  47. trigger_error('Database Connection Error: ' . $this->con->connect_errno . ': ' . $this->con->connect_error, 256);
  48. exit();
  49. }
  50. }
  51.  
  52. public function getConnectionObject()
  53. {
  54. return $this->con;
  55. }
  56.  
  57. public function query($qry)
  58. {
  59. $this->lastExecutedStatement = $this->prepareStatement($qry);
  60.  
  61. if (false === $this->lastExecutedStatement) {
  62. return false;
  63. }
  64.  
  65. $result = $this->lastExecutedStatement->execute();
  66.  
  67. if (!$result) {
  68. $this->error = $this->lastExecutedStatement->getError();
  69. $this->error .= $qry;
  70. }
  71.  
  72. return $result;
  73. }
  74.  
  75. public function prepareStatement($qry)
  76. {
  77. $this->con->stmt_init();
  78. $smt = $this->con->prepare($qry);
  79. .......................................................
  80. ...............................
  81. ..............
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement