Sqlx load/delete
Is there a better way do to this?
In log it prints twice
L 04/15/2012 - 21:11:38: [admin.amxx] Seems to work?
L 04/15/2012 - 21:11:38: [admin.amxx] Seems to work?
Maybe because it uses twice.
SQL_ThreadQuery( SqlTuple , "MySql" , Temp );
SQL_ThreadQuery( SqlTuple , "MySql" , Temp2 );
Is there a way to run it once with 2 querys?
creates table if not exists or removes expired.
PHP Code:
#include < amxmodx > #include < sqlx >
new cvar_HostName; new cvar_UserName; new cvar_PassWord; new cvar_DataBase; new cvar_Table;
new Handle:SqlTuple;
//==================================[ Plugin_Init ]===============================================//
public plugin_init( ) { register_plugin( "PLUGIN" , "VERSION" , "AUTHOR" ); cvar_HostName = register_cvar( "asd1" , "" ); cvar_UserName = register_cvar( "asd2" , "user451" ); cvar_PassWord = register_cvar( "asd3" , "" ); cvar_DataBase = register_cvar( "asd4" , "user451" ); cvar_Table = register_cvar( "asd5" , "asde44" ); MySql_Init( ); }
//==================================[ MySql_Init ]================================================//
public MySql_Init( ) { new SqlHost[ 64 ]; get_pcvar_string( cvar_HostName , SqlHost , charsmax( SqlHost ) ); new SqlUser[ 64 ]; get_pcvar_string( cvar_UserName , SqlUser , charsmax( SqlUser ) ); new SqlPass[ 64 ]; get_pcvar_string( cvar_PassWord , SqlPass , charsmax( SqlPass ) ); new SqlData[ 64 ]; get_pcvar_string( cvar_DataBase , SqlData , charsmax( SqlData ) ); SqlTuple = SQL_MakeDbTuple( SqlHost , SqlUser , SqlPass , SqlData ); new SqlTable[ 64 ]; get_pcvar_string( cvar_Table , SqlTable , charsmax( SqlTable ) ); new Temp[ 512 ]; formatex( Temp , charsmax( Temp ) , "CREATE TABLE IF NOT EXISTS `%s` (\ `id` int(12) NOT NULL auto_increment,\ `Nick` varchar(32) NOT NULL DEFAULT '',\ `Steam` varchar(32) NOT NULL DEFAULT '',\ `Password` varchar(32) NOT NULL,\ `Access` varchar(22) NOT NULL DEFAULT 'z',\ `Flags` varchar(5) NOT NULL DEFAULT 'a',\ `Expire` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',\ PRIMARY KEY (`id`) )" , SqlTable ); new Temp2[ 82 ]; formatex( Temp2 , charsmax( Temp2 ) , "DELETE FROM `%s` WHERE `Expire` <= NOW()" , SqlTable ); SQL_ThreadQuery( SqlTuple , "MySql" , Temp ); SQL_ThreadQuery( SqlTuple , "MySql" , Temp2 ); }
public MySql( FailState , Handle:Query , Error[ ] , Errcode , Data[ ] , DataSize ) { if( FailState == TQUERY_CONNECT_FAILED ) log_amx( "Could not connect to SQL database. [%d] %s" , Errcode , Error ); else if( FailState == TQUERY_QUERY_FAILED ) log_amx( "Query failed. [%d] %s" , Errcode , Error ); else { log_amx( "Seems to work?" ); } }
|