1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
-- Load driver
luasql = require "luasql.mysql"
env = assert (luasql.mysql())
con = assert(env:connect("test","root","xxxxx","localhost","3306"))
--CREATE TABLES
res = con:execute"DROP TABLE users"
res = assert (con:execute[[
	CREATE TABLE users(
	id INT UNSIGNED NOT NULL AUTO_INCREMENT,
	name VARCHAR(64) UNSIGNED,
	age TINYINT UNSIGNED,
	email VARCHAR(64),
	usgn INT,
	money INT,
	country VARCHAR(64),
	isadmin BIT(1),
	admin_lvl TINYINT UNSIGNED PRIMARY KEY (id)
	)
]])
--EXAMPLE DATABASES
info = {
	{	name="Marcell Csendes", age="20", email="sqpp15@gmail.com", money="55000", country="Los Santos", isadmin="true", adminlvl="12"}
	}
	
-- PAIRS	
for i, p in pairs (info) do
res = assert (con:execute(string.format([[
INSERT INTO users
VALUES ('%s', '%s')]], p.name, p.age, p.email, p.usgn, p.money, p.country, p.isadmin, p.adminlvl)
))
end
cur = assert (con:execute"SELECT name, email from people")
row = cur:fetch ({}, "a")
addhook("join","spawn")
function spawn(id)
	msg2(string.format (id, "©255000000 Name: %s, USGN: %s, Money: %s", row.name, row.usgn, row.money))
	row = cur:fetch (row, "a")
end
cur:close()
con:close()
env:close()