asterisk dialplan中MYSQL命令的使用

 

想在拨号计划中实现来电后根据来电号码查询数据库来选择被叫分机
 
所以用到了MYSQL命令:实现的拨号计划代码如下:
 
;添加根据来电号码查询数据库选择分机
exten => s,n,Set(CIDNUM=${CALLERID(num)})
exten => s,n,Noop(callerNum is now ${CIDNUM})
exten => s,n,Set(CIDNUM=${CALLERID(num)})
exten => s,n,Noop(callerNum is now ${CIDNUM})
exten => s,n,MYSQL(Connect connid localhost asteriskuser amp109 test)
exten => s,n,MYSQL(Query resultid ${connid} select\ destexten\ from\ calleridlookup\ where\ callernum=${CIDNUM})
exten => s,n,MYSQL(Fetch fetchid ${resultid} destexten)
exten => s,n,MYSQL(Clear ${resultid})
exten => s,n,MYSQL(Disconnect ${connid})
exten => s,n,GotoIf($["${fetchid}" == "0"]?done) ; leave loop if no row found
exten => s,n,Noop(var1 is ${destexten})
exten => s,n,Goto(from-did-direct,8991,1)
exten => s,n(done),Noop(lookup fail goto normal)
 
在mysql中添加数据库test,并在其中建立calleridlookup表:
 
create table calleridlookup(id smallint(6) NOT NULL auto_increment PRIMARY KEY, callernum varchar(20), destexten varchar(20));
 
MYSQL命令的使用方法请参考:http://www.voip-info.org/wiki/view/Asterisk+cmd+MYSQL

你可能感兴趣的:(数据库,mysql,职场,休闲,elastix)