2015-06-29 47 views
0

所以我試圖從lua SQL的命令中使用mySQL數據庫進行計數查詢。我想獲得表中的當前用戶數,但是我很遺憾將lua用作語言並將數據庫合併到它中。如何從luaSQL查詢中獲取結果?

到目前爲止,這是我所:

exec,err = connect:execute("SELECT count(user_id) AS count FROM Users") 
    testString = string.format("%d", exec:numrows()) 
    if exec:numrows() == 0 then 
     send_msg(receiver, teststring, ok_cb, false) 
    end 

我和另一個腳本檢查,它的價值在於它返回的是1,但是我想要得到行內的值...我將如何去做這個與luaSQL?

回答

0

好,而不是把這個困難我自己,我決定從SQL語句刪除計數命令,並使用內luaSQL的聲明numRows行,有點像這樣:

exec,err = connect:execute("SELECT user_id FROM Users") 
if exec:numrows() == 0 then 
    send_msg(receiver, "test", ok_cb, false) 
end 
相關問題