Jump to content

How to insert multiple values from select into table?


Recommended Posts

Can you give me a hint how do i insert values into table?

Heres the code i wrote

mytable = {}

function insertGangTable()
local connection = dbConnect( "sqlite", "data.db" )
local gang_list = dbQuery( connection, "SELECT id,name FROM gang_list" )
local gang_list_result = dbPoll(gang_list, -1)

if gang_list_result then
	for _,row in ipairs( gang_list_result ) do
		for _,value in pairs( row ) do
			table.insert(mytable,...) --- { [id] = "name" }
		end
	end
end
end

 

Link to comment
mytable = {}

function insertGangTable()
	local connection = dbConnect( "sqlite", "data.db" )
	local gang_list = dbQuery( connection, "SELECT id,name FROM gang_list" )
	local gang_list_result = dbPoll(gang_list, -1)

	if gang_list_result then
		for _,row in ipairs( gang_list_result ) do
			mytable[row["id"]] = row["name"] --- { [id] = "name" }
		end
	end
end

 

Edited by NeXuS™
  • Like 1
Link to comment
1 hour ago, NeXuS™ said:

mytable = {}

function insertGangTable()
	local connection = dbConnect( "sqlite", "data.db" )
	local gang_list = dbQuery( connection, "SELECT id,name FROM gang_list" )
	local gang_list_result = dbPoll(gang_list, -1)

	if gang_list_result then
		for _,row in ipairs( gang_list_result ) do
			mytable[row["id"]] = row["name"] --- { [id] = "name" }
		end
	end
end

 

Thakns m8

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...