-
Notifications
You must be signed in to change notification settings - Fork 2k
SQL Result Type #277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Which MySQL client are you using? Are you using the lua-resty-mysql library? If yes, you should consult its documentation for details on the output results. Basically, it is documented in the read_query method's documentation: https://github.com/agentzh/lua-resty-mysql#read_result That is, by default, you should access a single field in the form res[row_num][column_name], for instance,
accesses the "id" field in the 1st row of the resultset. But also be aware of the "compact_arrays" option in the "connect" method: https://github.com/agentzh/lua-resty-mysql#connect Regards, |
It did work.res[row_num][column_name]is OK. It returns a Lua table (res) describing the MySQL OK packet or result set packet for the query result. For queries corresponding to a result set, it returns an array holding all the rows. Each row holds key-value apirs for each data fields. But now I think it already do the job, because it said : "Each row holdskey-valueapirs for each data fields". Key-Value is the most info, but I ignored it , it's my fault. Thank you very much, Big Zhang^_^ At 2013-08-30 23:46:37,"Yichun Zhang" [email protected] wrote: Which MySQL client are you using? Are you using the lua-resty-mysql library? If yes, you should consult its documentation for details on the output results. Basically, it is documented in the read_query method's documentation: https://github.com/agentzh/lua-resty-mysql#read_result That is, by default, you should access a single field in the form res[row_num][column_name], for instance, res[1]["id"] accesses the "id" field in the 1st row of the resultset. But also be aware of the "compact_arrays" option in the "connect" method: https://github.com/agentzh/lua-resty-mysql#connect Regards, ¡ª |
If I were you, I would just use libraries like lua-cjson to dump the data structures ;) |
Yeah, it's a good idea. ÔÚ 2013-09-02 06:25:57£¬"Yichun Zhang" [email protected] дµÀ£º If I were you, I would just use libraries like lua-cjson to dump the data structures ;) ¡ª |
@StemonZhang I'm suggesting using lua-cjson temporarily for your local debugging purposes, not for the formal output in the final product. Anyway, I'm closing this. |
I am confused , what's the type of the SQL Result?
I used the Lua get the data stored in MySQL DB .
The SQL statement is db:query("select result from result_table order by data_time desc limit 1").
I want to get the result. But I don't know the type of it~
when I use like this:
The result is nil. But I directly used the same SQL Statement to the MySQL DB, it could get the result I wanted.
When I use like this:
It threw error: runtime error: [string "rewrite_by_lua"]:39: bad argument #1 to 'say' (non-array table found)
It's strange, I search the Internet ,but there is no answer about the type of the SQL Result.
THX~
The text was updated successfully, but these errors were encountered: