Raised This Month: $32 Target: $400
 8% 

Solved Storing Multiple Variables for DB query


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dustinandband
Senior Member
Join Date: May 2015
Old 07-09-2020 , 16:13   Storing Multiple Variables for DB query
Reply With Quote #1

So I have two database tables which are related.

One Main table:
https://i.imgur.com/PE28pek.png

The other table logs events:
https://i.imgur.com/nWvff2T.png

the id_of_Survival_Main (from LoggedEvents) is an integer that corrisponds with the id# of the main table.

My issue is that I have multiple events which I need to store somewhere until I know the id# from the main DB table (which won't happen after the main query is completed):
Spoiler


I was planning on having a key-value system where I can store these values (until the survival round ends and we know what the value of "id_of_Survival_Main" will be), and just iterate over all the stored values in the key-value system while adding each one to a transaction statement. I'm curious if there's a less hacky way of storing multiple pieces of data or is this the preferred method in a situation like this?
Spoiler

Last edited by dustinandband; 07-12-2020 at 01:37.
dustinandband is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 07-10-2020 , 08:40   Re: Storing Multiple Variables for DB query
Reply With Quote #2

I don't understand what you're trying to do, but the auto incremented id of the INSERT query can be accessed using results.InsertId https://sm.alliedmods.net/new-api/db...ltSet/InsertId
__________________
Peace-Maker is offline
dustinandband
Senior Member
Join Date: May 2015
Old 07-10-2020 , 10:37   Re: Storing Multiple Variables for DB query
Reply With Quote #3

1)
I won't know the value of the autoincrement ID# until after the main DB query is complete.

2)
Since I won't be able to log these events in real-time to the DB - i need a way of storing them somewhere.

3)
There could be any number of events getting logged per round ( 0 - 50+ )

Example:

Code:
name (char[])	authID (char[])		reason ((char[]))				time_formatted((char[]))	time_tick(int or char)
"dustin"		"84684684684"		"Idling while charged"			"105:40.50"					"15351511"

name (char[])	authID (char[])		reason ((char[]))				time_formatted((char[]))	time_tick(int or char)
"angel"			"64684684684"		"SMAC detection"				"110:20.27"					"15364684"
4)
I'm looking for methods of storing multiple strings so, for example,
The first variable "dustin" relates to the proper authID, reason, time_formatted, and time_tick

I'm thinking of either the key-value system that was in the OP, or maybe declaring 5 different arraylists and just iterating through that when I'm ready to log into the EventsLog database table.

But I'm wondering if there's any other methods for storing this info within the plugin until it’s ready to be logged into the database.

Edit:
nvm just ended up using arraylist method to store values.
Not sure why every time I ask a question regarding databases people get confused.

Spoiler

Last edited by dustinandband; 07-12-2020 at 01:35.
dustinandband 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 17:24.


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