[Asterisk-Users] Storing extension prefs. in MySQL

Chris A. Icide chris at netgeeks.net
Fri Sep 9 11:00:32 MST 2005


Andreas Sikkema wrote:

>asterisk-users-bounces at lists.digium.com wrote:
>
>  
>
>>I would like to store these seetings in a mysql database, so
>>that they are more easily accessible from a user
>>configuration page on a webserver. Since these settings need
>>to be checked in the dialplan for each call to the extension,
>>it seems a bit to much to have to connect, query and
>>disconnect from mysql every time. Is there any way to keep a
>>persistent connection to mysql that can be queried from the
>>dialplan? 
>>    
>>
>
>Well, if you do this before answering, nobody is going to 
>notice. Even querying during an answered call will have 
>hardly any outside consequences... 
>
>  
>
Using the MYSQL functions from asterisk-addons....

extensions.conf

[macro-open-connection]

exten => s,1,MYSQL(Connect connid .....
exten => s,2,SetVar(OPEN-CON=1)

[macro-close-connection]

exten => s,1,GotoIf(${OPEN-CON}?5)
exten => s,5,MYSQL(Close ${connid})

Then call the open macro when you first receive a call, and make sure in
your hangup (exten => h) function you call the close macro.  If you have
an include => hangup in all your contexts, the close macro will be
called anytime a hangup is received and it will close any connection you
opened for that call.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20050909/81925ec9/attachment.htm


More information about the asterisk-users mailing list