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})

 

 

 

转自:http://hwzyyx.javaeye.com/blog/576741

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/100512.html原文链接:https://javaforall.net

赞 (0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • jxls能把html转成excel吗,如何用XLSTransformer生成excel文件?jxls的使用方法

    jxls能把html转成excel吗,如何用XLSTransformer生成excel文件?jxls的使用方法jxls的使用方法:1)声明一个XLSTransformer对象,生成方式就是使用new操作符XLSTransformertransformer=newXLSTransformer();2)得到Template的FIle:StringxlsTemplateFileName=this.getClass().getClassLoader().getResource(“template.x…

    2022年7月24日
  • 快速排序(三种算法实现和非递归实现)

    快速排序(三种算法实现和非递归实现)快速排序(QuickSort)是对冒泡排序的一种改进,基本思想是选取一个记录作为枢轴,经过一趟排序,将整段序列分为两个部分,其中一部分的值都小于枢轴,另一部分都大于枢轴。然后继续对这两部分继续进行排序,从而使整个序列达到有序。递归实现:voidQuickSort(int*array,intleft,intright){assert(array);if(left>=

    2022年7月26日
  • pycharm中使用pyinstaller 来打包程序「建议收藏」

    pycharm中使用pyinstaller 来打包程序「建议收藏」本章是有关pyqt5最后一个简单的东西了,目前我使用pyqt5还是比较少的,如果以后需要其他项目的时候在记录吧,也是对2020年最后一天的结束吧。首先通过pycharm下载pyinstaller.下载后添加额外工具:name为:pyinstallerDescription:forpacketwindowsexeprogram:找到那安装包路径Argument中写:-F-w$FileNameWithoutExtension$.pyworki…

    2022年8月28日
  • Celer cBridge 主网上线:无缝桥接跨链和跨层流动性

    Celer cBridge 主网上线:无缝桥接跨链和跨层流动性CelercBridgev1.0版本今天正式主网上线!用户可以立即使用cBridge在Ethereum、Arbitrum、BinanceSmartChain以及Polygon进行高速低成本跨链和跨层转账。cBridge将会在短期内支持更多的layer2和layer1区块链的跨链转账。此外,任何人都将能够通过运行cBridge节点加入cBridge网络以提供跨链跨层流动性,同时通过收取手续费产生收益。cBridge是一个重要的里程碑,它标志着Celer将在未来的多链多层区块链扩容生态下,提..

    2022年6月4日
  • 每天学点GDB 3

    每天学点GDB 3

    2021年8月22日
  • Arduino使用HC05蓝牙模块与手机连接[通俗易懂]

    Arduino使用HC05蓝牙模块与手机连接[通俗易懂]通过本文,可以了解到以下内容:进入AT模式进行蓝牙基本参数设置Arduino蓝牙控制LED电路设计以及代码编写利用Andorid蓝牙串口调试软件测试功能进入At模式进行蓝牙基本参数设置想要使用Arduino的蓝牙模块,首先要对蓝牙模块进行基本参数设置。基本参数设置主要包含:蓝牙名称、模式以及匹配密码等。设置蓝牙模块可以使用USB-TTL连接电脑使用串口调试软

    2022年5月9日

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号