Hello,
avpops module has a new function which allow to execute raw SQL queries and store the result in AVPs.
avp_db_query(query, dest);
The query given as parameter can contain pseudo-variables. Using this function you can benefit of full database system features, being able to do joins, unions, etc. Old db-related functions are in place since they are faster for their usage case.
The documentation of the of avpops module was updated and posted at:
http://openser.org/docs/modules/1.1.x/avpops.html
A small example of usage: limit the number of calls done in the last day:
if(is_method("INVITE") && !has_totag()) { if(avp_db_query("select count(*) from acc where username='$fU' and domain='$fd' and method='INVITE' and timestamp>=$Ts-24*3600", "$avp(i:234)")) { if(avp_chech("$avp(i:234)", "ge/i:10")) { sl_send_reply("403", "too many calls in the last day"); exit(); } } }
Cheers, Daniel