Advertisement
Guest User

Untitled

a guest
Dec 24th, 2016
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 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.  
  5. hook OnGameModeInit() {
  6. database->intialize("localhost", "root", "", "db");
  7. }
  8.  
  9. hook OnGameModeExit() {
  10. database->destruct();
  11. }
  12.  
  13. //Some functions that would be such as public function smth()
  14. database::initialize(host[], user[], pass[], db[]) {
  15. new MySQLOpt:options = mysql_init_options();
  16. mysql_set_option(options, SERVER_PORT, 3306);
  17. mysql_set_option(options, AUTO_RECONNECT, false);
  18. mysql_set_option(options, POOL_SIZE, 2);
  19. mysql_connect(host, user, pass, db, options);
  20. if(mysql_errno(SQL::mc) != 0) {
  21. log->write("Could not create connection with the database manager.");
  22. }
  23. }
  24.  
  25. database::destruct() {
  26. mysql_close();
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement