Skip to content

SQL Result Type #277

Closed
Closed
@StemonZhang

Description

@StemonZhang

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:

                    if table.getn(res) ~= 0 then
                            ngx.say(res[1][1]) ;
                    end

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:

                    if table.getn(res) ~= 0 then
                            ngx.say(res[1]) ;
                    end

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~

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions