Chamberlien Posted May 7, 2012 Share Posted May 7, 2012 okay so I was wondering how to select something like from the data base 'rpserver' and the table 'settings' and it has a MOTD line how would I be able to show that using paradise MySQL so like it shows on a outputChatBox? Link to comment
Castillo Posted May 7, 2012 Share Posted May 7, 2012 local result = exports.sql:query_assoc_single ( "SELECT * FROM settings WHERE name = 'motd'" ) if ( result ) then outputChatBox ( tostring ( result.value ) ) end Database cannot be specified when using MTA Paradise game mode, you have just one database set on "sql/mysql.lua". Link to comment
Chamberlien Posted May 7, 2012 Author Share Posted May 7, 2012 Yea I know I'm not working on MTA Paradise I'm improving on Venux btw Thanks Link to comment
Castillo Posted May 7, 2012 Share Posted May 7, 2012 You're welcome. P.S: "value" is the column name. Link to comment
Callum Posted May 7, 2012 Share Posted May 7, 2012 local result = exports.sql:query_assoc_single ( "SELECT * FROM settings WHERE name = 'motd'" ) if ( result ) then outputChatBox ( tostring ( result.value ) ) end Database cannot be specified when using MTA Paradise game mode, you have just one database set on "sql/mysql.lua". Selecting * can be a potential performance deficiency. You should only select the columns you need, using the format; "SELECT column1, column2, column3 FROM table WHERE column4 = 'value' LIMIT 1" PS: Using 'limit 1' makes the server stop the query after fetching 1 result. This is very good for increasing performance (so if the result is row 500 or 100000, it doesn't loop the other 99500 rows). Link to comment
Chamberlien Posted May 7, 2012 Author Share Posted May 7, 2012 I'm just using three simple MySQL tables also I have advanced on this code structure thanks again( no one else repply ) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now