Raised This Month: $ Target: $400
 0% 

MySQL query Question/Problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Spriite
Member
Join Date: Aug 2010
Old 05-06-2012 , 03:53   MySQL query Question/Problem
Reply With Quote #1

[EN]
During the query the players lose their connection to the server, and only returned when the query is completed. How do I fix this?

Obs: I'm using the SQLx.

[BP]
Durante a consulta os jogadores perdem a conexão com o servidor, e só voltam quando a consulta é concluída. Como eu conserto isso?

Obs: Eu estou usando o SQLx.

Last edited by Spriite; 05-06-2012 at 04:01.
Spriite is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 05-06-2012 , 04:12   Re: MySQL query Question/Problem
Reply With Quote #2

I've only experienced this issue when I tried to connect to the database during gameplay, instead of during plugin_init().

Show your code.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
Spriite
Member
Join Date: Aug 2010
Old 05-06-2012 , 12:00   Re: MySQL query Question/Problem
Reply With Quote #3

PHP Code:
new const g_sqlTable[] = "DataTable";
new const 
g_DataBase[] = "DataBase_test";
public 
plugin_init()
{
     ...
     
sql_init();
     ...
}
sql_init()

     
SQL_SetAffinity("mysql");
 
     
g_SqlTuple SQL_MakeDbTuple("???.???.???.???""xxxx""zzzz"g_DataBase);
 
     new 
Sql_Cache[400];
     
formatex(Sql_Cachecharsmax(Sql_Cache), "CREATE TABLE `%s` \
     (`Index` INTEGER(20) AUTO_INCREMENT PRIMARY KEY , \
     `Conta` VARCHAR( 64 ) NOT NULL , \
     `Senha` VARCHAR( 64 ) NOT NULL , \
     `AmmoPacks` INT( 20 ) NOT NULL DEFAULT '0' , \
     `Blocked` INT( 20 ) NOT NULL DEFAULT '0' )"
g_sqlTable);
 
     
SQL_ThreadQuery(g_SqlTuple"handle_create_table"Sql_Cache);
}
public 
handle_create_table(FailStateHandle:Query,Error[], ErrcodeData[], DataSize)
{
     new 
fail_msg[300];
     if(
Error[0] && Errcode != 1050)
     {
          
formatex(fail_msgcharsmax(fail_msg), "MySQL Error: %s (%d)"ErrorErrcode);
          
set_fail_state(fail_msg);
          return;
     }
     new 
errcodeerror[100];
     
g_SqlCon SQL_Connect(g_SqlTupleerrcodeerrorcharsmax(error));
 
     if(
error[0])
     {
          
formatex(fail_msgcharsmax(fail_msg), "MySQL Error: %s (%d)"errorerrcode);
          
set_fail_state(fail_msg);
          return;
     }
 
     if(
Errcode == 1050)
          return;
     else
     {
          
SQL_FreeHandle(Query);
          
Query SQL_PrepareQuery(g_SqlCon"INSERT INTO `%s` ( `Index` , `Conta` , `Senha` , `Blocked` ) VALUES ( 1 , 'null' , %d , 1 )"g_sqlTableget_gametime());
          
SQL_Execute(Query);
          
SQL_QueryError(Queryerror99);
          
SQL_FreeHandle(Query);
 
          if(
error[0])
          
server_print("SQL Error: %s (%d)"errorerrcode);
     }

[EN]
Obs: Most of my queries and I do using SQL_PrepareQuery and SQL_Execute.

[BP]
Obs: A maioria das minhas consultas eu faço utilizando SQL_PrepareQuery e SQL_Execute.

Last edited by Spriite; 05-06-2012 at 12:41.
Spriite is offline
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 05-06-2012 , 18:23   Re: MySQL query Question/Problem
Reply With Quote #4

Thats because when you use SQL_PrepareQuery the native waits from de mysql answer.... Change your MySQL system and replace SQL_PrepareQuery with SQL_ThreadQuery

The link in my signature is a register system using MySQL, it use SQL_ThreadQuery if you want an example.
__________________

Last edited by Neeeeeeeeeel.-; 05-06-2012 at 18:24.
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:31.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode