Page 1 of 1

hello sirs(how to access a database)

PostPosted: Sat Jun 04, 2011 1:49 am
by acbhaskar123
plz tell me how to store database in asterisk.
i.e for example i want to access employee details database.
i tried it by using MYSQL application
[dbtest]

exten => _X.,1,MYSQL(Connect connid localhost asterisk dbpass Book1.xlsx)
exten => _X.,2,MYSQL(Query resultid ${connid} SELECT\ scriptname\ from\ mac2pin\ where\ userid=${CALLERIDNAME})
exten => _X.,3,MYSQL(Fetch fetchid ${resultid} AGIScript)
exten => _X.,4,MYSQL(Clear ${resultid})
exten => _X.,5,MYSQL(Disconnect ${connid})
exten => _X.,6,GotoIf($[${fetchid}]?7:9)
exten => _X.,7,AGI(${DefaultAGIScript},${EXTEN})
exten => _X.,8,Hangup
exten => _X.,9,AGI(${AGIScript},${EXTEN})
exten => _X.,10,Hangup


exten => 5005,1,Answer()
exten => 5005,2,Set(DB(test/data)=100)
exten => 5005,3,Set(NewVar=${DB(test/data)})
exten => 5005,4,SendText(${NewVar})
exten => 5005,5,Hangup()

even then also i could not able to connect to database
i used asterisk-addons (i have installed this)
i have added res_mysql.conf also.

[dbtest]

exten => _X.,1,MYSQL(Connect connid localhost asterisk dbpass asterisk)
exten => _X.,2,MYSQL(Query resultid ${connid} SELECT\ id\ from\ astdb\ where\ name=${CALLERIDNAME})
exten => _X.,3,MYSQL(Fetch fetchid ${resultid} AGIScript)
exten => _X.,4,MYSQL(Clear ${resultid})
exten => _X.,5,MYSQL(Disconnect ${connid})
exten => _X.,6,GotoIf($[${fetchid}]?7:9)
exten => _X.,7,AGI(${DefaultAGIScript},${EXTEN})
exten => _X.,8,Hangup
exten => _X.,9,AGI(${AGIScript},${EXTEN})
exten => _X.,10,Hangup

[mysqlcal]
exten => 555,1,Answer
exten => 555,n,MYSQL(Connect connid localhost myuser mypass db1)
exten => 555,n,NoOp(${id})
exten => 555,n,NoOp(${name})
exten => 555,n,MYSQL(Query resultid ${connid} INSERT INTO `astdb` (`id`) VALUES ('${CALLERID(id)}'))
exten => 555,n,MYSQL(Query resultid ${connid} UPDATE `astdb` SET `status` = \'ANSWERED\' WHERE `id`=${id} AND `name`=${name})


plz help me
thank u
ur's regards
Bhaskar reddy

PostPosted: Sat Jun 04, 2011 4:34 pm
by DhwaniTechnologies