asterisk使用mysql_Asterisk 操作mysql数据库的应用

It is necessary in many application with the dialplan that we need to qurey from the database and pass the result to the aserisk dialplan command.Previously we had to use to use AGI (Asterisk Gateway Interface) for accomplish this task.This is we need some programming part to be done.Non programmers don’t worry now an application called MYSQL() is avilable with asterisk 1.4 and above.We can use this application as normal asterisk application and can give the MSQL qurey inside it. For this to work we have to install asterisk-addon first.

syntax :

MYSQL(Connect connid dhhost dbuser dbpass dbname)

Connects to a database. Arguments contain standard MySQL parameters passed to function mysql_real_connect. Connection identifer returned in ${connid}. If the connection wasn’t possible, then ${connid} == “”.

MYSQL(Query resultid ${connid} query-string)

Executes standard MySQL query contained in query-string using established connection identified by ${connid}. Result of query is stored in ${resultid}.

MYSQL(Fetch fetchid ${resultid} var1/ var2/ …/ varN)

If any rows are available to select, ${fetchid} is set to 1 and a single row is fetched from a result set contained in ${resultid}. The return fields are assigned to ${var1}, ${var2} … ${varN} respectively. If no rows are left to select, ${fetchid} is set to 0 and ${var1}, ${var2} … ${varN} remain unchanged.

MYSQL(Clear ${resultid})

Frees memory and data structures associated with result set.

MYSQL(Disconnect ${connid})

Disconnects from named connection to MySQL.

Example

[mysqlcal] exten => 555,1,Answer exten => 555,n,MYSQL(Connect connid localhost bipin bipin voice_alerts) exten => 555,n,NoOp(${cnum}) exten => 555,n,NoOp(${jid}) exten => 555,n,MYSQL(Query resultid ${connid} INSERT INTO `callerinfo` (`number`) VALUES ('${CALLERID(num)}')) exten => 555,n,MYSQL(Query resultid ${connid} UPDATE `callerinfo` SET `status` = /'ANSWERED/' WHERE `job`=${jid} AND `number`=${cnum})

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值