AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Write same thing but to 2 databases/tables (https://forums.alliedmods.net/showthread.php?t=308388)

4ever16 06-18-2018 14:57

Write same thing but to 2 databases/tables
 
So basicly i want to write data to both databases/tables.
The wierd thing is that it only writes to database2.
I want it to write to both what am i doing wrong?

PHP Code:

public SavePlayer(id)
{
    if(!
pLoaded[id]) return PLUGIN_HANDLED;
    
    if (
pPoints[id] < 0)
        
pPoints[id] < 0;
    
    new 
Name[64], steam[64];
    
get_user_name(idName63);
    
    
get_user_authid(idsteam63);
    
    static 
szQuery[3800];
    
formatexszQuery3799"REPLACE INTO `DATABASETABLE1` (`player_id`, `player_name`, `kills`, `deaths`, `headshots`, `aces`, `m_aces`, `mix_played`, `mix_lost`, `mix_won`, `mix_draw`, `points`, `last_online`) VALUES ('%s', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', NOW());"steamGetSecureName(Name), pKills[id], pDeaths[id], pHeadshots[id], pAces[id], pMiniAces[id], pMixPlayed[id], pMixLost[id], pMixWon[id], pMixDraw[id], pPoints[id]);
    
formatexszQuery3799"REPLACE INTO `DATABASETABLE2` (`player_id`, `player_name`, `kills`, `deaths`, `headshots`, `aces`, `m_aces`, `mix_played`, `mix_lost`, `mix_won`, `mix_draw`, `points`, `last_online`) VALUES ('%s', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', NOW());"steamGetSecureName(Name), gKills[id], gDeaths[id], gHeadshots[id], gAces[id], gMiniAces[id], gMixPlayed[id], gMixLost[id], gMixWon[id], gMixDraw[id], gPoints[id]);
            
    
#if AMXX_VERSION_NUM >= 183
        
SQL_SetCharset(g_hTuple,"utf8");
    
#endif
    
    
SQL_ThreadQueryg_hTuple"QuerySetData"szQuery);

    return 
PLUGIN_CONTINUE;



^SmileY 06-18-2018 15:03

Re: Write same thing but to 2 databases/tables
 
Did you formatting the query two times and used the SQL_ThreadQuery one time, what result you expected?

4ever16 06-18-2018 15:11

Re: Write same thing but to 2 databases/tables
 
Quote:

Originally Posted by ^SmileY (Post 2597781)
Did you formatting the query two times and used the SQL_ThreadQuery one time, what result you expected?

Dont understant what you mean but i use only one database. I just want it to write same thing but to 2 tables not 2 different databases.

^SmileY 06-18-2018 15:27

Re: Write same thing but to 2 databases/tables
 
Quote:

Originally Posted by 4ever16 (Post 2597783)
Dont understant what you mean but i use only one database. I just want it to write same thing but to 2 tables not 2 different databases.

Code:

public SavePlayer(id)
{   
    if (pPoints[id] < 0)
        pPoints[id] < 0;
   
    new Name[64], steam[35];
    get_user_name(id, Name, 34);
   
    get_user_authid(id, steam, 34);
   
    new szQuery[3800];
    formatex( szQuery, 3799, "REPLACE INTO `DATABASETABLE1` (`player_id`, `player_name`, `kills`, `deaths`, `headshots`, `aces`, `m_aces`, `mix_played`, `mix_lost`, `mix_won`, `mix_draw`, `points`, `last_online`) VALUES ('%s', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', NOW());", steam, GetSecureName(Name), pKills[id], pDeaths[id], pHeadshots[id], pAces[id], pMiniAces[id], pMixPlayed[id], pMixLost[id], pMixWon[id], pMixDraw[id], pPoints[id]);
    SQL_ThreadQuery( g_hTuple, "QuerySetData", szQuery);
   
    formatex( szQuery, 3799, "REPLACE INTO `DATABASETABLE2` (`player_id`, `player_name`, `kills`, `deaths`, `headshots`, `aces`, `m_aces`, `mix_played`, `mix_lost`, `mix_won`, `mix_draw`, `points`, `last_online`) VALUES ('%s', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', NOW());", steam, GetSecureName(Name), gKills[id], gDeaths[id], gHeadshots[id], gAces[id], gMiniAces[id], gMixPlayed[id], gMixLost[id], gMixWon[id], gMixDraw[id], gPoints[id]);
    SQL_ThreadQuery( g_hTuple, "QuerySetData", szQuery);
       
    #if AMXX_VERSION_NUM >= 183
        SQL_SetCharset(g_hTuple,"utf8"); // WTF?
    #endif
}


4ever16 06-18-2018 16:21

Re: Write same thing but to 2 databases/tables
 
Thanks it worked!


All times are GMT -4. The time now is 12:48.

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