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


相关推荐

  • js跳转页面并刷新(本页面跳转)

    1、跳转常用方法:window.location.href=”index.php”;window.history.back(-1);//类似于按钮,参数是负几,就后退几次。window.navigate(“index.jsp”);//navigate对象包含有关浏览器的信息,也可以作为页面跳转,后面直接加要跳转的地方。self.location.href=index.htm;

    2022年4月11日
    48
  • Day03,Python文件的常见操作

    Day03,Python文件的常见操作Day03,Python文件的常见操作

    2022年4月21日
    55
  • socket默认端口号(socket和端口的关系)

    from:http://www.iana.org/assignments/port-numbers
     
    ////////////////////////////////////////////////////////////////////////////////
     PORTNUMBERS(lastupdated2010-09-24)Theportnumbersaredividedintothreeranges:theWel

    2022年4月17日
    179
  • opencv实现imfill_使用opencv实现matlab中的imfill填充孔洞功能

    opencv实现imfill_使用opencv实现matlab中的imfill填充孔洞功能使用opencv实现matlab中的imfill填充孔洞功能,整体思路如下:1.首先给原始图像四周加一圈全0,并保存为另一幅图像2.使用floodFill函数给新图像进行填充,种子点设置为Point(0,0),填充颜色为全白。因为原始图像四周加了一圈0,因此使用floodFill填充之后,整个图像除了原始图像中内部的点是黑色之外其他地方全是白色。3.将填充之后…

    2025年11月8日
    4
  • python pymssql_Python模块-pymssql[通俗易懂]

    python pymssql_Python模块-pymssql[通俗易懂]Python默认的数据库是SQLlite,不过它对MySql以及SQLserver的支持也可以。如果想链接操作SQLserver,需使用第三方包pymssqlpymssql是一个Python的数据库接口,基于FreeTDS构建,对_mssql模块进行了封装,遵循Python的DBAPI规范,而FreeTDS是一个C语言连接sqlserver的公共开源库工作原理使用connect创建连接对象;…

    2022年6月16日
    39
  • Python实现softmax函数「建议收藏」

    Python实现softmax函数:PS:为了避免求exp(x)出现溢出的情况,一般需要减去最大值。#-*-coding:utf-8-*-importtensorflowastfimportnumpyasnpdefsoftmax(x,axis=1):#计算每行的最大值row_max=x.max(axis=axis)…

    2022年4月14日
    493

发表回复

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

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