Regarding avp_db_query

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Regarding avp_db_query

Vishal Pai
Hi Everyone 

I just want to know what is correct to fetch all the row from database using avp_db_query. Currently I am getting only first row in result.

One more think I want to know is it possible to get array of for variable in Opensips configuration file.


Thanks

Vishal Pai 

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Regarding avp_db_query

Razvan Crainea-3
Hi, Vishal!

You can find the answer to your question in the function's documentation[1]:  If the result gives many rows, then multiple AVPs with corresponding name will be added.

Consider the following query:
avp_db_query("select group where username='$tu'", "$avp(group)");

The first line of the result can be accessed using $avp(group) (or $(avp(group)[0])), the second line $(avp(group)[1]), and so on.

[1] http://www.opensips.org/html/docs/modules/2.4.x/avpops.html#idp3469424

Best regards,
Răzvan Crainea
OpenSIPS Developer
www.opensips-solutions.com
On 11/24/2017 08:56 PM, Vishal Pai wrote:
Hi Everyone 

I just want to know what is correct to fetch all the row from database using avp_db_query. Currently I am getting only first row in result.

One more think I want to know is it possible to get array of for variable in Opensips configuration file.


Thanks

Vishal Pai 


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Regarding avp_db_query

Vishal Pai
Thanks i got that....


On Mon, Nov 27, 2017 at 2:03 PM, Răzvan Crainea <[hidden email]> wrote:
Hi, Vishal!

You can find the answer to your question in the function's documentation[1]:  If the result gives many rows, then multiple AVPs with corresponding name will be added.

Consider the following query:
avp_db_query("select group where username='$tu'", "$avp(group)");

The first line of the result can be accessed using $avp(group) (or $(avp(group)[0])), the second line $(avp(group)[1]), and so on.

[1] http://www.opensips.org/html/docs/modules/2.4.x/avpops.html#idp3469424

Best regards,
Răzvan Crainea
OpenSIPS Developer
www.opensips-solutions.com
On 11/24/2017 08:56 PM, Vishal Pai wrote:
Hi Everyone 

I just want to know what is correct to fetch all the row from database using avp_db_query. Currently I am getting only first row in result.

One more think I want to know is it possible to get array of for variable in Opensips configuration file.


Thanks

Vishal Pai 


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users



_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users