[SR-Users] fetch data from Mysql Using Kamailio
Alberto Sagredo
alberto.sagredo at avanzada7.com
Thu Apr 28 16:49:15 CEST 2016
Hi.
Try something like this
$var(valor)=0;
$var(valor) = $dbr(ra=>[0,0]);
Use $var(valor) for that purpose.
I will check address table if you plan to use some ip authentication or
similar.
Its more powerful if you are looking for that
BR
2016-04-28 16:19 GMT+02:00 Shahid Mehmood <shahid.ge4 at gmail.com>:
> Thanx ur kind reply
>
> sql_query("cb", "select ip from ext where ext='$rU'", "ra");
> $var(a)= sql_result_free("ra");
>
> i have an other question . how i get data return from sql query. i get 1
> from sql_result_free("ra"); i need ip address like below
>
> mysql> select ip from ext where ext=202
> -> ;
> +----------------+
> | ip |
> +----------------+
> | 192.168.55.157 |
> +----------------+
> 1 row in set (0.00 sec)
>
>
>
> On Thu, Apr 28, 2016 at 4:36 PM, Alberto Sagredo <
> alberto.sagredo at avanzada7.com> wrote:
>
>> Ups Sorry
>>
>> #!ifdef WITH_MYSQL
>> loadmodule "db_mysql.so"
>> #!endif
>>
>> modparam("sqlops","sqlcon","cb=>mysql://root:pass@IP/kamailio")
>>
>> if($rU=~"^1[0-9][0-9]$")
>> {
>> sql_query("cb", "select asterisk from x where extension='$rU'","valora");
>> sql_result_free("valora");
>>
>> }
>>
>> With no issues..
>>
>> Any error on mysql¿
>>
>> BR
>>
>>
>>
>> 2016-04-28 13:33 GMT+02:00 Alberto Sagredo <alberto.sagredo at avanzada7.com
>> >:
>>
>>> Hi
>>>
>>> Im my case
>>>
>>>
>>> modparam("sqlops","sqlcon","ca=>mysql://root:pass@IP/kamailio")
>>>
>>>
>>>
>>>
>>>
>>> 2016-04-28 12:13 GMT+02:00 Shahid Mehmood <shahid.ge4 at gmail.com>:
>>>
>>>> Dear All,
>>>> i am getting error when i trying to fetch data from mysql
>>>> data base using kamailio.
>>>>
>>>> i have following code into kamailio.cfg file
>>>>
>>>> loadmodule "db_mysql.so"
>>>> loadmodule "sqlops.so"
>>>>
>>>> ................................
>>>> modparam("sqlops","sqlcon","ca=>mysql://root:123456@
>>>> localhost/kamailio")
>>>> ...............................
>>>> ...............................
>>>>
>>>> sql_query("ca", "select * from ext", "ra");
>>>> sql_result_free("ra");
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> *Apr 24 06:30:31 kamalio /usr/sbin/kamailio[1385]: INFO: rr
>>>> [rr_mod.c:160]: mod_init(): outbound module not availableApr 24 06:30:31
>>>> kamalio /usr/sbin/kamailio[1385]: INFO: usrloc [hslot.c:53]:
>>>> ul_init_locks(): locks array size 1024Apr 24 06:30:31 kamalio
>>>> /usr/sbin/kamailio[1385]: ERROR: sqlops [sqlops.c:276]: fixup_sql_query():
>>>> invalid connection [ca]Apr 24 06:30:31 kamalio /usr/sbin/kamailio[1385]:
>>>> ERROR: <core> [route.c:1189]: fix_actions(): fixing failed (code=-1) at
>>>> cfg://etc/kamailio/kamailio.cfg:514Apr 24 06:30:31 kamalio
>>>> /usr/sbin/kamailio[1385]: ERROR: <core> [route.c:1189]: fix_actions():
>>>> fixing failed (code=-1) at cfg://etc/kamailio/kamailio.cfg:534*
>>>>
>>>> --
>>>> Shahid Mehmood
>>>>
>>>> _______________________________________________
>>>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>>>> sr-users at lists.sip-router.org
>>>> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>>>>
>>>>
>>>
>>
>> _______________________________________________
>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>> sr-users at lists.sip-router.org
>> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>>
>>
>
>
> --
> Shahid Mehmood
>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20160428/08779a3b/attachment.html>
More information about the sr-users
mailing list