Raised This Month: $ Target: $400
 0% 

MySQL query Question/Problem


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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 23:20.


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