Anubhav Posted August 3, 2014 Share Posted August 3, 2014 Hey guyz, After searching and researching about OOP in 1.4, I found the function list of OOP ( server ). I wanted to make my scripts easier but I din't understood how to use some functions. THESE are they - create (function: dbConnect) exec (function: dbExec) query (function: dbQuery) please help Link to comment
Anubhav Posted August 3, 2014 Author Share Posted August 3, 2014 Any help? Please help me guyz! Don't be lazy to answer, I realy want to know how to use this this functions! Link to comment
Saml1er Posted August 3, 2014 Share Posted August 3, 2014 local handler = Connection.create ( "sqlite", "file.db", "", "", "share=0" ) handler:exec(...) handler:query(...) Link to comment
Anubhav Posted August 3, 2014 Author Share Posted August 3, 2014 Explain it to me please Link to comment
Anubhav Posted August 3, 2014 Author Share Posted August 3, 2014 Thanks, I got everything! Link to comment
Blaawee Posted August 3, 2014 Share Posted August 3, 2014 Here is an example connection = {} connection_mt = { __index = connection } local validDatabaseType = { mysql = true, sqlite = true } function connection:create( databaseType, host, username, password, options ) if databaseType and type( databaseType ) ~= 'string' then outputDebugString ( 'Bad argument @argument #1 Must be string. ', 0, 112, 112, 112 ); return end if not validDatabaseType[ databaseType ] then outputDebugString ( 'Bad argument @argument #1 Unvalid datebase type. ', 0, 112, 112, 112 ); return end if databaseType == 'sqlite' then username = ''; password = ''; else username = username; password = password; end local connet = { type = databaseType, host = host, username = username, password = password, options = options or '', connection = dbConnect( databaseType, host, username, password, options ) }; setmetatable( connet, connection_mt ); return connet; end function connection:exec( query, ... ) if query and type( query ) == 'string' then return dbExec( self.connection, query, ... ); end end local myConnetion = connection:create( 'sqlite', 'path' ) myConnetion:exec( 'blablabla', blablabla ) 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