Hi guys, I have problem use mysql in extensions.conf. I have table like this:
===========================
| name | number1 | number2 |
| 1000 | 100 | 50 |
| 1001 | 200 | 70 |
===========================
ok, I’m trying Select number1 and number2 when ${CALLERID(num)} is 1000, I tried everything from http://www.voip-info.org/wiki/view/Asterisk+cmd+MYSQL, but doesn’t matter what i used, I can´t get 100 or 50… my extensions.conf:
MYSQL(Connect connid localhost user pass asterisk)
MYSQL(Query resultid ${connid} SELECT 'number1' FROM test WHERE name=${CALLERID(num)})
MYSQL(Fetch fetchid ${resultid} number1)
if I use Noop(${resultid}) i get 2, and if I use Noop(${fetchid}) i get 1, and ${var1}, ${var2} is everytime empty.
THX
exten => in,n,MYSQL(Connect connid ${mysqlin})
exten => in,n,MYSQL(Query resultid ${connid} SELECT\ *\ from\ callback\ where\ callid=\'${CALLERID(num)}\'\ and\ \'${EPOCH}\'\ >\ \`timestamp\` )
exten => in,n(fetchrow),MYSQL(Fetch foundrow ${resultid} callid timestamp stop refer Names)
exten => in,n,NoOp(resultid ${resultid} foundrow ${foundRow} )
exten => in,n,GotoIf($["${foundRow}" != "1"]?done)
exten => in,n,NoOp(Looping ${callid} )
exten => in,n,Goto(fetchrow) ; continue loop if row found
exten => in,n(done),Noop(Done ${callid} TIME ${timestamp} STOP ${stop} REFER ${refer} NAMES ${Names} RESULT ${resultid})
exten => in,n,MYSQL(Clear ${resultid})
exten => in,n,MYSQL(Disconnect ${connid})
This is the code we use to get data from mysql
THX for your post, but when I use
i get WARNING[3125]: app_mysql.c:392 aMYSQL_query
it´s mean bad syntax.
What kind of Asterisk you use PLS???