Reputation:
I'm trying to apply my entry in the lua in a code for sql in C.
My lua file has the following code:
prepare_sql = {
flvdb = "flv_database";
};
My lua code is as follows:
lua_getglobal(L, "prepare_sql");
lua_getfield(L, -1, "flvdb");
p->flvdb = lua_tostring(L, -1);
My C code before applying lua code worked normally:
sql_prepare(SqlPrepare *stax, const char *qry, ...);
Before:
if(SQLPASS != sql_prepare(sqltp, "INSERT INTO `flv_database` (`date`, `value`, `count`) VALUES (NOW(), '%d', '%d')", p->value, p->cnt))
After:
if(SQLPASS != sql_prepare(sqltp, "INSERT INTO `%s` (`date`, `value`, `count`) VALUES (NOW(), '%d', '%d')", p->flvdb, p->value, p->cnt))
Before the code worked well, after applying lua he can't capture the name that is in the file. Does anyone have an idea of what can be?
Upvotes: 0
Views: 73
Reputation: 671
Because you cannot prepare a query with a variable table name. Your Lua code is ok.
Upvotes: 2