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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Jenkins的三种启动方式「建议收藏」

    Jenkins的三种启动方式「建议收藏」前置条件Java8环境,参考:点击查看。(所有)docker环境,下载(第二种)ApacheTomcat环境,下载(第三种)一、war包启动下载Jenkins的war包打开终端命令行,找到war所在的路径运行java-jarjenkins.war浏览器打开http://localhost:8080,将会看到下图结果二、docker启动打开命令行终端或power…

    2022年5月18日
    543
  • 架构之业务架构[通俗易懂]

    架构之业务架构[通俗易懂]业务架构之产品经理的职责产品经理的职责用户的原始需求往往是零散和碎片化的,产品经理的职责就是:告诉用户,系统长什么样子;告诉开发,他要实现什么功能。产品经理定义了系统的外表。产品经理的职责:1、收集用户的原始需求,2、梳理成一个个业务流程,每个业务流程由多个业务步骤组成。一个业务步骤包含三部分的内容:输入、输出和业务功能。3、需求梳理好后,产品经理会把每个步骤具体化为页面原型。在原型中,会以直观的方式给出各个步骤的输入或输出,以及用户的操作过程,最后再把这些页面串起来,形成一个业

    2022年10月12日
    4
  • spring-schedul实现动态添加定时任务

    spring-schedul实现动态添加定时任务

    2021年7月12日
    104
  • android代码签名和混乱的包装

    android代码签名和混乱的包装

    2022年1月7日
    57
  • docker 镜像构建_docker生成镜像

    docker 镜像构建_docker生成镜像前言如果我们已经安装了一个python3的环境,如果另一台机器也需要安装同样的环境又要敲一遍,很麻烦,这里可以配置Dockerfile文件,让其自动安装,类似shell脚本Dockerfile编写

    2022年7月29日
    6
  • Jlink或者stlink用于SWD接口下载程序

    Jlink或者stlink用于SWD接口下载程序最近要使用stm32f103c8t6最小系统板,直接ISP串口下载程序太麻烦,就想着使用swd接口来调试。结果:通过SWD接口下载程序成功,但调试失败,还不知原因,会的的人麻烦交流一下。SWD接口:3.3VDIO(数据)CLK(时钟)GND1.首先声明jlink和stlink都有jtag和swd调试功能。jlink接口如下:如图,我使用的就是VCC…

    2022年4月25日
    53

发表回复

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

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