[Freeswitch-users] how to select 2nd row of sql query result in lua
Steven Ayre
steveayre at gmail.com
Sat Dec 6 13:17:40 MSK 2014
The function you pass to dbh:query is a callback. It is run for every row
in the result set, in order.
1) Will be qrow on 2nd invocation
2) 'count = count + 1' on each invocation
3) Print on all invocations. You should be seeing that already, so perhaps
the 2nd row isn't selected by your SQL query?
On 6 December 2014 at 05:31, Shabbir abbasi <shabbirabbasi92 at gmail.com>
wrote:
> if i execute a query in mysql select dialprefix,rateinitial from
> cc_ratecard where (dialprefix='001' or dialprefix='00123') ORDER BY
> LENGTH(dialprefix) DESC;
>
> result
> row1 | 001 | 0.01000 |
> row22 | 00123 | 0.02000 |
>
> and this is lua code
>
> local rates = {}
> local count = "";
>
> assert(dbh:query(query, function(qrow)
> for key, val in pairs(qrow) do
> rates[key] = val
> freeswitch.consoleLog("INFO"," rates :"..key.. "..="..val.." \n")
> end
> count = qrow.count;
> end))
>
> questios is
> 1 how to select 2nd row from result ?
> 2 how to count total rows ?
> 3 how to print all 2 rows in console ?
>
> any suggestios wellcome
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://confluence.freeswitch.org
> http://www.cluecon.com
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20141206/1ae0aee1/attachment.html
Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users
mailing list