-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paths_SQL.lua
More file actions
24 lines (21 loc) · 959 Bytes
/
s_SQL.lua
File metadata and controls
24 lines (21 loc) · 959 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
if ( tostring ( get ( "CONNECTION_TYPE" ) ):lower() == "mysql" ) then
outputConsole ( "Attempting to connect as MySQL... Please wait")
db = dbConnect( "mysql", "dbname="..tostring(get("DATABASE_NAME"))..";host="..tostring(get("MYSQL_HOST"))..";port="..tostring(get("MYSQL_PORT"))..";unix_socket=/opt/lampp/var/mysql/mysql.sock", tostring(get("MYSQL_USER")), tostring(get("MYSQL_PASS")), "share=1;autoreconnect=1" );
elseif ( tostring ( get ( "CONNECTION_TYPE" ) ):lower() == "sqlite" ) then
db = dbConnect ( "sqlite", tostring(get("DATABASE_NAME")) .. ".sql" );
else
error ( tostring(get("CONNECTION_TYPE")) .. " is an invalid SQL connection -- valid: mysql, sqlite" );
end
if not db then
print ( "The database has failed to connect")
return
else
print ( "Database has been connected")
end
function db_query ( ... )
local data = { ... }
return dbPoll ( dbQuery ( db, ... ), - 1 )
end
function db_exec ( ... )
return dbExec ( db, ... );
end