Nice feature, well done
I launch you a feature request : -)
What "should" be done...
From what I understood, you insert the entries as lines with an ID.
This ID can be used, but its merely an index [0..100] for the IG line entries.
Forget about these ID’s, or add them to the lines that are the most recent ones, like that, they correspond with the IG values.
What about this approach, in pseudo code:
Get the table (the 100 or less lines) from CP.lua
Find the last (from time point of view) line in your SQL table
Find the next, more recent line, in the CP.lua array – that isn’t in the SQL table.
Add all new values from CP.lua to SQL table from there.
Like this, the GuildHistory table will grow in time, and becomes a persistent Guild History log.
Better add an admin section that enables stripping for the last xx days (months) or xx max entries in the GuildHistory SQL table (or even both option for busy Guilds).
Or: let the table grow, but retrieve only the last XX lines at max for showing purposes.
This should be done because many shared web serves only offer 32 Mb of memory, and I already have a player with more then 6000 PvP logs => the server explodes when SELECTing that one ^^