Advertisement
Guest User

Untitled

a guest
Dec 24th, 2016
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. // Like in PHP, I like to use -> and/or :: for the OOP shit
  2. #define database-> database_
  3. #define database:: database_
  4. #if defined this
  5. #undef this
  6. #endif
  7. #define this database
  8.  
  9. hook OnGameModeInit() {
  10. database->intialize("localhost", "root", "", "db");
  11. }
  12.  
  13. hook OnGameModeExit() {
  14. database->destruct();
  15. }
  16.  
  17. //Some functions that would be such as public function smth()
  18. database::initialize(host[], user[], pass[], db[]) {
  19. new MySQLOpt:options = mysql_init_options();
  20. mysql_set_option(options, SERVER_PORT, 3306);
  21. mysql_set_option(options, AUTO_RECONNECT, false);
  22. mysql_set_option(options, POOL_SIZE, 2);
  23. mysql_connect(host, user, pass, db, options);
  24. if(mysql_errno(SQL::mc) != 0) {
  25. log->write("Could not create connection with the database manager.");
  26. }
  27. }
  28.  
  29. database::destruct() {
  30. mysql_close();
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement