X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=libs%2Fluci-lib-nixio%2FaxTLS%2Fwww%2Flua%2Ftest_sql2.lua;fp=libs%2Fluci-lib-nixio%2FaxTLS%2Fwww%2Flua%2Ftest_sql2.lua;h=a2f6ee12dcdb8fbd1268dc8ca65df88e674d9342;hp=0000000000000000000000000000000000000000;hb=1bb4822dca6113f73e3bc89e2acf15935e6f8e92;hpb=9edd0e46c3f880727738ce8ca6ff1c8b85f99ef4 diff --git a/libs/luci-lib-nixio/axTLS/www/lua/test_sql2.lua b/libs/luci-lib-nixio/axTLS/www/lua/test_sql2.lua new file mode 100644 index 000000000..a2f6ee12d --- /dev/null +++ b/libs/luci-lib-nixio/axTLS/www/lua/test_sql2.lua @@ -0,0 +1,24 @@ +require"postgres" + +local env = assert (luasql.postgres ()) +local conn = assert (env:connect ("luasql-test", "tomas")) +local cur = assert (conn:execute ("select count(*) from t1")) +local total = tonumber (cur:fetch()) +cur:close() +local aleatorio = math.random(total) +local cur = assert (conn:execute ("select * from t1, t2 where b = d and a != "..2*aleatorio)) + +cgilua.htmlheader() +cgilua.put ("Aleatorio = "..aleatorio.."
\n") + +local a,b,c,d = cur:fetch() +cgilua.put ("\n") +while a do +-- cgilua.put ("") + a,b,c,d = cur:fetch() +end +cgilua.put ("
",a,"",b,"",c,"",d,"
\n") + +cur:close() +conn:close() +env:close()