• MySQL SELECT in lua table structure?
    3 replies, posted
Hi, I'm starting to use SQL as a saving system rather than .txt, and I have a question about table structure. Say I have a MySQL table that looks like this: [code] id |money |name |ownerid 1 |10000 |"Whatever" |"STEAM_0:0:xxxxxxxx" [/code] and I set a var to a query I call on it that looks like this: [lua] local faction = tmysql.query( "SELECT * FROM table" ) [/lua] Would the table's structure look like this: [lua] faction[1] = { 1, 10000, "Whatever", "STEAM_0:x:xxxxxxxx" } [/lua] Or would it look like this: [lua] faction["id"] = { 1 } faction["money"] = { 10000 } faction["name"] = "Whatever" faction["ownerid"] = "STEAM_0:x:xxxxxxxx" [/lua] Or am I thinking completely wrong and it looks totally different than the two examples I just posted?
[QUOTE=Chief Tiger;24456080]Hi, I'm starting to use SQL as a saving system rather than .txt, and I have a question about table structure. Say I have a MySQL table that looks like this: [code] id |money |name |ownerid 1 |10000 |"Whatever" |"STEAM_0:0:xxxxxxxx" [/code] and I set a var to a query I call on it that looks like this: [lua] local faction = tmysql.query( "SELECT * FROM table" ) [/lua] Would the table's structure look like this: [lua] faction[1] = { 1, 10000, "Whatever", "STEAM_0:x:xxxxxxxx" } [/lua] Or would it look like this: [lua] faction["id"] = { 1 } faction["money"] = { 10000 } faction["name"] = "Whatever" faction["ownerid"] = "STEAM_0:x:xxxxxxxx" [/lua] Or am I thinking completely wrong and it looks totally different than the two examples I just posted?[/QUOTE] I think it would look like: [lua] faction[1]["id"] = 1 faction[1]["money"] = 10000 faction[1]["name"] = "Whatever" faction[1]["ownerid"] = "STEAM_0:x:xxxxxxxx" [/lua] Also if you look how it's used [url=http://gmodmodules.googlecode.com/svn/trunk/gm_tmysql2/readme.txt]in the examples of the readme[/url], I don't think it's as simple as defining the query as a variable.
Ok, thanks!
Sorry, you need to Log In to post a reply to this thread.