[asterisk-users] hwo to stok variable wiith menu

Dale Noll dnoll at wi.rr.com
Fri Nov 25 12:54:20 CST 2011


On 11/25/2011 10:48 AM, salaheddine elharit wrote:
>
> thanks for your response
> i use mysql like a database and my question when the customer press 3 
> in context menu i want to stok this variable in a table in my database 
> and i want to get this variable after
> could you please give an exemple like below
> thanks and regards
> [menu]
> exten => s,1,Background(${sounds_path}menu)
> exten => 0,1,Goto(menu,s,1)
> exten => 1,1,Goto(appel,s,1)
> exten => 2,1,Goto(message,s,1)
>
> exten => 3,1,Goto(support,s,1)
>
> exten => s,2,goto(menu,s,1)
> exten => i,1,Playback(${sounds_path}erreur-saisie)
> exten => i,2,Goto(menu,s,1)
> exten => t,1,Goto(menu,s,1)
>

It is difficult to get a good example because I do not know what you are 
looking to save.  You say you want to store the variable, but the only 
variable you have in this case is the digit the user entered, in this 
case '3'.  If you are trying to count the number of times callers press 
option '3', then it is a simple update.

If you have the app_mysql module compiled and loaded you can user the 
MYSQL() app.
http://www.voip-info.org/wiki/view/Asterisk+cmd+MYSQL

If you do not want would prefer to setup an ODBC connection, that is a 
bid more complex as you have to setup unixODBC ( /etc/odbcinst.ini, 
/etc/odbc.ini ), then setup res_odbc(/etc/asterisk/res_odbc.conf) and 
func_odbc (/etc/asterisk/func_odbc.conf).

How you update the database from within dialplan depends on which access 
method you choose.

Assume you have a mysql table with two columns:
option_name    varchar(15)
count                int


You could write something like this if you are using app_mysql

exten => 3,1,NoOp(User chose support option)
exten => 3,n,MYSQL(Connect connid localhost database_user 
database_password database_name)
exten => 3,n,MYSQL(Query resultid ${connid}  update counter_table set 
count = count + 1 where option_name = 'support')
exten => 3,n,MYSQL(Clear ${resultid})
exten => 3,n,MYSQL(Disconnect ${connid})
exten => 3,n,Goto(support,s,1)




-- 
"The truth speaks for itself. I'm just the messenger."
      Lyta Alexander - Babylon 5

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20111125/1db78292/attachment.htm>


More information about the asterisk-users mailing list