-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.lua
More file actions
55 lines (49 loc) · 1.45 KB
/
test.lua
File metadata and controls
55 lines (49 loc) · 1.45 KB
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
49
50
51
52
53
54
require "mysql"
function print_r ( t )
local print_r_cache={}
local function sub_print_r(t,indent)
if (print_r_cache[tostring(t)]) then
print(indent.."*"..tostring(t))
else
print_r_cache[tostring(t)]=true
if (type(t)=="table") then
for pos,val in pairs(t) do
if (type(val)=="table") then
print(indent.."["..pos.."] => "..tostring(t).." {")
sub_print_r(val,indent..string.rep(" ",string.len(pos)+8))
print(indent..string.rep(" ",string.len(pos)+6).."}")
else
print(indent.."["..pos.."] => "..tostring(val))
end
end
else
print(indent..tostring(t))
end
end
end
sub_print_r(t," ")
end
local db, err = mysql.connect('localhost', 'root', '12345qwert')
--print(db)
--print(err)
db:select_db('art')
db:set_charset("utf-8")
local rc = db:exec("DELETE FROM `ssc_user_bankcard` WHERE BankId = '15813';")
--print(db:insert_id())
print(db:affected_rows())
local data, rc = db:fetch_one("SELECT * FROM `agency_reports` LIMIT 1")
if not data then
print(db:error())
else
print_r(data)
end
print_r(rc)
print("\r\n\r\n")
local data, rc = db:fetch_all("SELECT * FROM `agency_reports` LIMIT 3")
if not data then
print(db:error())
else
print_r(data)
end
print_r(rc)
db:close()