Hello Elijah,
You can pass a function as second argument to dbh:query, like so:
dbh = freeswitch.Dbh(odbc_dsn, odbc_user, odbc_pass)
dbh:query("select * from some_table", function(row) -- here it loops through all rows
for key, val in pairs(row) do -- here it loops through all columns
stream:write(string.format("%25s : %s\n", key, val))
end
stream:write("\n")
end))
This will run the anonymous function for each row, where each iteration of the function will be passed a row in the form of a table.
Each row (table) will have the following syntax:
{ ["column_name_1"] = "row_value_1", ["column_name_2" = "row_value_2" }
There's more info here:
and here:
kind regards,
Leon
On Nov 24, 2010, at 1:11 AM, elijah wrote:
Could you demonstrate how to iterate through multiple returned rows in Lua from the function Dbh:query?
_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org