Here is another example or two.<div><br></div><div>Set module parameter to grab an extra column (tag) in a dbaliases table:</div><div>modparam("avpops", "db_scheme", "alias_scheme:table=dbaliases;username_col=username;domain_col=domain;value_col=tag;value_type=string")</div>
<div><br></div><div>In the config use the alias scheme (send in the uri of the RURI and store in avp 120):</div><div>avp_db_load( "$ru/uri", "$avp(120)/$alias_scheme" );</div><div><br></div><div>Assuming the tag column contains the customer class, use it to load values from the (default) usr_preferences table:</div>
<div>avp_db_load("$avp(120)", "a");</div><div><br></div><div>You can also load avp values based on various headers. Use request user from RURI:</div><div>avp_db_load("$ru", "a");</div>
<div><br></div><div>The first form will look for rows in usr_preferences where the uuid column match what is contained in avp 120. The second form will look for rows in which the username and domain columns match the username and domain of the RURI. If the domain is looked at is a module parameter. The avp's that get set are the attribute column and the value the avp is set to is the value column.</div>
<div><br></div><div>Here are a couple rows from the usr_preferences table:</div><div><br></div><div>| id | uuid | username | domain | attribute | type | value | last_modified |</div>
<div><br></div><div>| 37 | 2000 | | | no-nat-support | 0 | Y | 0000-00-00 00:00:00 |</div><div><br></div><div>| 28 | | 9194397461 | <a href="http://trunking.bsltech.net">trunking.bsltech.net</a> | userdebug | 0 | Y | 2010-08-25 00:00:00 |</div>
<div><br></div><div>And finally, use those values:</div><div><br></div><div><div> if( is_avp_set("$avp(userdebug)/s") )</div><div> {</div><div> xlog("L_INFO", "Turning on debug in inbound call due to user prefs flag for call $ci from $fU \n");</div>
<div> setflag(1);</div><div> }</div></div><div><br></div><div><div> if( !is_avp_set("$avp(no-nat-support)/s") )</div><div> {</div><div> bm_start_timer("media_proxy_benchmark"); #keep track of how long it's taking to talk to relays</div>
<div> engage_media_proxy();</div></div><div> more interesting stuff....</div><div> }</div><div><br></div><div><br></div><div>Richard</div><div><br></div><div><br><div class="gmail_quote">
On Mon, May 28, 2012 at 2:23 PM, Ali Pey <span dir="ltr"><<a href="mailto:alipey@gmail.com" target="_blank">alipey@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
avp_db_query("insert into SIP_REG(TIMESTAMP, SIP_USERNAME, DOMAIN, AGENT, CONTACT, EXPIRES, SOURCE, NET_TYPE, SERVER) values ('CURRENT_TIMESTAMP', '$fU', '$fd', '$ua', '$ct', '$hdr(Expires)', '$avp(i:42)', 'NATED', 'Primary OpenSIPS' )");<div>
<br></div><div>Regards,</div><div>Ali<br><br><div class="gmail_quote"><div><div class="h5">On Sun, May 27, 2012 at 3:07 AM, prasad kelkar <span dir="ltr"><<a href="mailto:durga144@gmail.com" target="_blank">durga144@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">hello,<br>I tried using AVPpops module to connect to table in mysql.<br>I cant acces value<br>
Please give me example code.<br>
Thank You<br>
<br></div></div>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
<br></blockquote></div><br></div>
<br>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
<br></blockquote></div><br></div>