Monthly Target: $400 Donations: $334
 83% 

Sqlx load/delete


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mucx
Member
Join Date: Mar 2011
Location: Estonia
Old 04-15-2012 , 14:14   Sqlx load/delete
Reply With Quote #1

Is there a better way do to this?

In log it prints twice
L 04/15/2012 - 21:118: [admin.amxx] Seems to work?
L 04/15/2012 - 21:118: [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 
SqlHost64 ]; get_pcvar_stringcvar_HostName SqlHost charsmaxSqlHost ) );
    new 
SqlUser64 ]; get_pcvar_stringcvar_UserName SqlUser charsmaxSqlUser ) );
    new 
SqlPass64 ]; get_pcvar_stringcvar_PassWord SqlPass charsmaxSqlPass ) );
    new 
SqlData64 ]; get_pcvar_stringcvar_DataBase SqlData charsmaxSqlData ) );
    
    
SqlTuple SQL_MakeDbTupleSqlHost SqlUser SqlPass SqlData );
    
    new 
SqlTable64 ];
    
get_pcvar_stringcvar_Table SqlTable charsmaxSqlTable ) );
    
    new 
Temp512 ];
    
formatexTemp charsmaxTemp ) , "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 
Temp282 ];
    
formatexTemp2 charsmaxTemp2 ) , "DELETE FROM `%s` WHERE `Expire` <= NOW()" SqlTable );
    
    
SQL_ThreadQuerySqlTuple "MySql" Temp );
    
SQL_ThreadQuerySqlTuple "MySql" Temp2 );
}

public 
MySqlFailState 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?" );
    }


Last edited by Mucx; 04-15-2012 at 15:01.
Mucx is offline
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 21:27.


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