MorganaSacani
Active Member
- Joined
- Sep 20, 2022
- Messages
- 87
- Solutions
- 1
- Reaction score
- 32
Hello World!
I created an auxiliary table for my database called 'test_server_storage'.
In this table there are two columns. The 'player_id' column and the 'item_id' column.
I'm trying to collect all ids that are in the columns called 'item_id' of a certain player, in this case 'player_id'. And after collecting the ids, I'm trying to make these columns receive the value 0.
I started by creating a 'while do' loop structure, but it only works once.
The function collects only the first value of the 'item_id' column and then clears all columns of the same name.
This is the part of my algorithm I'm struggling to get working.
I don't understand much about SQL commands:
Does anyone know how to help me?
I remembered one more problem:
In addition to this algorithm cleaning all 'item_id', it cleans all 'player_id', even though they are not the same id as my player.
I created an auxiliary table for my database called 'test_server_storage'.
In this table there are two columns. The 'player_id' column and the 'item_id' column.
I'm trying to collect all ids that are in the columns called 'item_id' of a certain player, in this case 'player_id'. And after collecting the ids, I'm trying to make these columns receive the value 0.
I started by creating a 'while do' loop structure, but it only works once.
The function collects only the first value of the 'item_id' column and then clears all columns of the same name.
This is the part of my algorithm I'm struggling to get working.
I don't understand much about SQL commands:
Lua:
local playerGuid = player:getGuid()
local inbox = player:getSlotItem(CONST_SLOT_STORE_INBOX)
while playerGuid == result.getNumber(db.storeQuery("SELECT player_id FROM test_server_storage WHERE player_id = " .. playerGuid), "player_id") do
inbox:addItem(itemId_, 1) -- Here I need my algorithm to add all the id present in the 'item_id' column for my character.
db.query("UPDATE test_server_storage SET item_id = 0")
db.query("UPDATE test_server_storage SET player_id = 0")
end
Post automatically merged:
I remembered one more problem:
In addition to this algorithm cleaning all 'item_id', it cleans all 'player_id', even though they are not the same id as my player.