Asterisk mysql lookup


Configure MySQL Resource



;dbhost =
;dbport = 3306
dbsock = /var/run/mysqld/mysqld.sock

dbname = asterisk_db
dbuser = asterisk_db
dbpass = asterisk_db

dbcharset = utf8

 ; warn, createclose, createchar

connection checking

realtime mysql status

general connected to asterisk_db on socket file /var/run/mysqld/mysqld.sock with username asterisk_db for 0 seconds.




; mysql

; MYSQL(Connect connid dhhost dbuser dbpass dbname)
; established connection identified by ${connid}
exten => _5XX,n,MYSQL(Connect connid asterisk asterisk asterisk)

; MYSQL(Query resultid ${connid} query-string)
; Result of query is stored in ${resultid}
exten => _5XX,n,MYSQL(Query resultid ${connid} SELECT name, goto FROM route WHERE cid='${CALLERID(number)}')

; The return fields are assigned to ${var1}, ${var2} ... ${varN} respectively.
exten => _5XX,n,MYSQL(Fetch fetchid ${resultid} name goto)

exten => _5XX,n,NoOp("We found: ${name} ${goto}")

; Frees memory
MYSQL(Clear ${resultid})

; Disconnects
MYSQL(Disconnect ${connid})