Guest User

Untitled

a guest
Jan 3rd, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. namespace BraxBBDD;
  2.  
  3. require_once $_SERVER['DOCUMENT_ROOT'].'/config/cfg.php';
  4.  
  5. class MySQL {
  6. private $server;
  7. private $username;
  8. private $password;
  9. private $database;
  10. public $mysqli; // Ver si la visibilidad afecta a los traits
  11.  
  12. public function __construct() {
  13. $this->server = 'localhost';
  14. $this->username = 'root';
  15. $this->password = '';
  16. $this->database = 'db';
  17.  
  18. $this->mysqli = new mysqli($this->server, $this->username, $this->password, $this->database);
  19. $this->mysqli->set_charset('utf8');
  20. }
  21.  
  22. /**
  23. * This function will make a query to the DB.
  24. * @param string $sql [It's a SQL string]
  25. * @return object|false [If succesfull, it will return an object, else, it will return false]
  26. */
  27. protected function query(string $sql) {
  28. if (!empty($sql)) {
  29. if ($response = $this->mysqli->query($sql)) {
  30. if (DEBUG === true) {
  31. echo '['.HOUR.'] MySQLi query() DEBUG [SQL Executed]: '.$sql.PHP_EOL;
  32. }
  33.  
  34. return $response;
  35. } else {
  36. if (DEBUG === true) {
  37. echo '['.HOUR.'] MySQLi query() DEBUG [SQL Executed with ERROR * ]: '.$sql.PHP_EOL;
  38. }
  39.  
  40. return false;
  41. }
  42. } else {
  43. if (DEBUG === true) {
  44. echo '['.HOUR.'] MySQLi Query DEBUG [SQL]: The query is empty.'.PHP_EOL;
  45. }
  46.  
  47. return false;
  48. }
  49. }
  50.  
  51. namespace BraxUsuarios;
  52. require_once $_SERVER['DOCUMENT_ROOT'].'/config/cfg.php';
  53. spl_autoload_register('Braxautoload');
  54.  
  55. class Usuarios extends BraxBBDDMySQL {
  56. use BraxTraitsCRUDTrait;
  57.  
  58. private $Panel,
  59. $Accesos,
  60. $Referidos,
  61. $GameServers;
  62.  
  63. public function __construct() {
  64. $this->Panel = new BraxPanelPanel();
  65. $this->Accesos = new AccesosAccesos();
  66. $this->Referidos = new BraxReferidosPostsReferidos();
  67. $this->GameServers = new BraxGameServersGameServers();
  68. }
  69. }
Add Comment
Please, Sign In to add comment