环境Elastix2.5
编辑/etc/asterisk/extensions.conf
[from-internal] exten=>#,1,Answer //这里设置的是#号键 exten=>#,n,MySql(connect connid localhost root 123456 asteriskcdrdb) //连接mysql 操作 ;exten=>#,n,MySql(query resultidr ${connid} insert into test (msg) values ('${CALLERID(num)}')) //测试插入 exten=>#,n,MySql(query resultidr ${connid} select dst as a,uniqueid as b from cdr where src=${CALLERID(num)} order by uniqueid desc limit 1) //获取上一个呼叫记录数据 exten=>#,n,MySql(Fetch foundrow ${resultidr} a b) //取出变量 exten=>#,n,MySql(clear ${resultidr}) //清空结果集 exten=>#,n,MySql(query resultidr ${connid} update cdr set userfield='OK' where uniqueid=${b}) //更新 exten=>#,n,MySql(clear ${resultidr}) exten=>#,n,MySql(disconnect ${connid}) //断开连接 exten=>#,n,saydigits(${a}) //报被叫号码 exten=>#,n,Playback(custom/mark_ok) //“已经标记成功”语音 exten=>#,n,Hangup //挂机 //后面是原来的拨号方案 include => from-internal-noxfer include => from-internal-xfer include => bad-number ; auto-generated
保存完毕后需要重载asterisk生效。
63 queries in 1.977 seconds |