• Fetching Query Value with MySQL
    4 replies, posted
I'm attempting to get the value from my database "Money" but I can NOT figure out how to fetch the value itself. This is what I have, and I cannot figure the method to grab the value. I've been trying just about every function in the documentation with print tables and regular prints and I just get "Query <Random Numbers>" or a string that is really useless to me such as: "1: money = 1120" local query = DB_INFO:query( "SELECT money FROM users WHERE steamid = '" .. id .. "';" )
Are you using the internal sql library or an external module like mysqloo?
Did you try reading usage examples provided on the GitHub you linked? MySQLOO/query.lua at master · FredyH/MySQLOO · GitHub
Here's an example of a callback function function GetDataQuery( str, callback ) local d = db:query(str) --db is the database d:start() --Not sure if this is needed this code is old function d:onSuccess(data) --If the query is successful callback(data) --Pass the data in the callback function end end local q = "SELECT * FROM table" GetDataQuery(q, function(tbl) --every row you receive from your query are indexed numeratically in the table i.e tbl[1] is first entry end)
Thanks so much MrManiak, I was too tunnel visioned on the documentation, completely forgot there was examples sitting there for me.
Sorry, you need to Log In to post a reply to this thread.