Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.53 KB | None | 0 0
  1. void SQL_CheckTables() {
  2.     g_hDB.Query(SQL_OnCheckedTables, "SHOW TABLES;", 0, DBPrio_High);
  3. }
  4.  
  5. public void SQL_OnCheckedTables(Database hDB, DBResultSet hResults, const char[] szError, any data) {
  6.     bool bClients   = false;
  7.     bool bChannels  = false;
  8.     char szTableName[20];
  9.  
  10.     while (hResults.FetchRow()) {
  11.         hResults.FetchString(0, szTableName, sizeof(szTableName));
  12.  
  13.         if (StrEqual(szTableName, "vc_channels")) {
  14.             bChannels = true;
  15.         } else if (StrEqual(szTableName, "vc_clients")) {
  16.             bClients = true;
  17.         }
  18.  
  19.         if (bChannels && bClients) {
  20.             g_bSQL_Ready = true;
  21.             break;
  22.         }
  23.     }
  24.  
  25.     if (!bChannels || !bClients) {
  26.         SQL_CreateTables(!bChannels, !bClients);
  27.     }
  28. }
  29.  
  30. void SQL_CreateTables(bool bChannels, bool bClients) {
  31.     Transaction hTransaction = new Transaction();
  32.  
  33.     if (bChannels) {
  34.         hTransaction.AddQuery(g_szQueriesTpl_CreateTables_Channels[g_iDriverType]);
  35.         hTransaction.AddQuery(g_szQueriesTpl_IndexesTables_Channels[g_iDriverType]);
  36.         hTransaction.AddQuery(g_szQueriesTpl_AITables_Channels[g_iDriverType]);
  37.     }
  38.  
  39.     if (bClients) {
  40.         hTransaction.AddQuery(g_szQueriesTpl_CreateTables_Clients[g_iDriverType]);
  41.         hTransaction.AddQuery(g_szQueriesTpl_IndexesTables_Clients[g_iDriverType]);
  42.         hTransaction.AddQuery(g_szQueriesTpl_AITables_Clients[g_iDriverType]);
  43.     }
  44.  
  45.     g_hDB.Execute(hTransaction, SQL_OnTablesCreated_OK, SQL_OnTablesCreated_Error, 0, DBPrio_High);
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement