• MySQLOO: Getting data from the database
    3 replies, posted
Sorry for the noob question, but im new to mysql and i want to grab data from a database. Also if someone could explain to me in like 5 minutes how to use mysql or even link me somewhere helpful :D
[QUOTE=Acecool;44481745]I'm working on creating database tutorials: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/database/_connecting_with_mysqloo.lua.html[/url] [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/database/_connecting_with_tmysql.lua.html[/url] [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/database/_connecting_with_fallbacks_in_place.lua.html[/url] I'm creating new tutorials when I can; additionally the MySQL DB Lua should be 100% SERVERside.[/QUOTE] I personally haven't read/seen these nor do I like his naming methods because i find it confusing, but you could try that. [URL="http://facepunch.com/showthread.php?t=1383497"]*quoted from this thread*[/URL] Here's a brief descriptions on how a mysql server works. Database - contains tables, there can be an almost infinite amount all containing different data Table - contains the rows and columns that contain data. Row - the name of the information stored. It's the index in a table. Column - holds the data A SQL query - 'talks' to the database and tells the the database to retrieve and/or modify data. --This example may be used when shutting down a server and telling the SQL database that no one is on the server: "UPDATE clients SET onserver = 0 WHERE onserver = 1 " it tells the server to update the table 'clients', set the index of 'onserver' to the value of 0 any time ("WHERE") the index of 'onsever' is the value of '1' [URL="http://facepunch.com/showthread.php?t=1220537"]reading the module examples may help.[/URL] You could also read though problems other people have asked for help in the thread and read the responses.
I looked through the examples but couldnt find what i was looking for. How would i go about receiving data from one of the tables?
It depends on the table. You're query will look something like this [code] "SELECT * FROM clients WHERE steamid = '" .. ply:SteamID() .. "'" [/code] select all information from the table clients where the steamid is the player's steamid This assumes the table is called clients and that you have a row called 'steamid' with the player's steamid along with the other data in the same row. it might return something like this for a single person [code] table = { [1] = { ['name'] = 'pandaman09' ['job'] = 'potato' ['steamid'] = 'STEAM_0_0_123456' } } [/code] and you can retrieve the infomation like this table["1"].name OR table["1"]["name"] , it would return 'panda' table["1"].steamid OR table["1"]["steamid"], it would return 'STEAM_0_0_123456' *please note that both table["1"]["name"] and table["1"].steamid do the exact same thing, they are just written differently
Sorry, you need to Log In to post a reply to this thread.