Raised This Month: $51 Target: $400
 12% 

Solved Write same thing but to 2 databases/tables


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
4ever16
Veteran Member
Join Date: Apr 2015
Old 06-18-2018 , 14:57   Write same thing but to 2 databases/tables
Reply With Quote #1

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;


Last edited by 4ever16; 06-18-2018 at 16:21.
4ever16 is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 06-18-2018 , 15:03   Re: Write same thing but to 2 databases/tables
Reply With Quote #2

Did you formatting the query two times and used the SQL_ThreadQuery one time, what result you expected?
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
4ever16
Veteran Member
Join Date: Apr 2015
Old 06-18-2018 , 15:11   Re: Write same thing but to 2 databases/tables
Reply With Quote #3

Quote:
Originally Posted by ^SmileY View Post
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.

Last edited by 4ever16; 06-18-2018 at 15:12.
4ever16 is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 06-18-2018 , 15:27   Re: Write same thing but to 2 databases/tables
Reply With Quote #4

Quote:
Originally Posted by 4ever16 View Post
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
}
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 06-18-2018 at 15:29.
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
4ever16
Veteran Member
Join Date: Apr 2015
Old 06-18-2018 , 16:21   Re: Write same thing but to 2 databases/tables
Reply With Quote #5

Thanks it worked!
4ever16 is offline
Reply



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


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