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

[SQLite] Combining Rows like nVault


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
WAR3DM
Senior Member
Join Date: Mar 2016
Old 09-06-2016 , 21:17   [SQLite] Combining Rows like nVault
Reply With Quote #1

Hello! I'll keep things short & simple.

I'm stuck with 500k rows in 1 table. This causes extreme lag anytime someone connects to the server.

The Current Structure:



What I'm Trying to Accomplish:



Create:
PHP Code:
    "CREATE TABLE `skills` ( `player_id` int(8) NOT NULL default '0', `skill_id` int(8) NOT NULL default '0', `skill_level` int(8) default NULL, PRIMARY KEY  (`player_id`,`skill_id`) );"

Load:
PHP Code:
// Select the right Table
    
formatszQuerycharsmaxszQuery ), "SELECT `skill_id`, `skill_level` FROM `skills` WHERE ( `player_id` = '%d' );"p_data[id][PLAYER_UNIQUEID] );
    
query SQL_PrepareQueryg_DBConnszQuery );

// While we have a result!
    
new iSkillID 0;
    while ( 
SQL_MoreResultsquery ) )
    {
        
iSkillID SQL_ReadResultquery);
        
p_data_skill[id][iSkillID] = SQL_ReadResultquery);

        
SQL_NextRowquery );
    } 

Save:
PHP Code:
// Now we need to save the skill levels!
for ( new iSkillID 0iSkillID MAX_SKILLSiSkillID++ )
{
    
formatexszQuery511"REPLACE INTO `skills` ( `player_id` , `skill_id` , `skill_level` ) VALUES ( '%d', '%d', '%d' );"iUniqueIDiSkillIDp_data_skill[id][iSkillID] );
    
query SQL_PrepareQueryg_DBConnszQuery );


How would I loop all skill_levels from a player_id into 1 field like shown in the 2nd image? Any help is GREATLY appreciated!

Last edited by WAR3DM; 09-07-2016 at 19:57.
WAR3DM 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 07:13.


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