Lua mysql, need a way to avoid data

I need a way to avoid data for mysql statements in lua. I am used to doing something like mysql_real_escape_string () in php, but cannot find the equivalent in lua using mysql (con: escape () worked when I used sqlite3). I read that prepared statements are a solution, but it doesn't seem to work for me. What am I doing wrong?

require "luasql.mysql"
env = assert (luasql.mysql())
con = env:connect("db_name", "user", "pass", "localhost")
local stmt = con:prepare([[
    SELECT * FROM `user` 
    WHERE `login` = :a AND `pass` = :b LIMIT 1
]])
stmt.a = "some_user"
stmt.b = "some_pass"

These errors are with "attempt to invoke prepare method (nil value)".

If I try to run the direct SELECT * execute on con, it works fine, so the connection is completed, but this preparation statement does not work (it does not even recognize how the method is ready for action).

+3
source share
1 answer

, prepare ​​ LuaSQL , , , ?

con:escape(yourQuery) , , .

+5

All Articles