Advertisement
oquidave

asterisk db query

Oct 22nd, 2012
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. extension.conf
  2.  
  3. [subBalance]
  4. exten=>751,1,Answer()
  5. same=>n(auth),Set(ID=${ODBC_AUTHUSER(${EXTEN}, 1234)});send the exten & PIN of this caller and get their ID
  6. same=>n,NoOp(the ID is ${ID})
  7. same=>n,GotoIf($[${ISNULL(${ID})}]?auth:getbalance);request to enter pin again else get their current balance
  8. same=>n(getbalance),Set(BALANCE=${ODBC_BALANCE(${ID})});send the ID of this user and get their balance
  9. same=>n,SayNumber(${BALANCE});tell user their current balance
  10. same=>n,Hangup()
  11. //func_odbc.conf
  12.  
  13. [AUTHUSER]
  14. dsn=asterisk
  15. readsql=SELECT id FROM `user_accounts` where exten=${ARG1} and pin=${ARG2}
  16.  
  17. [BALANCE]
  18. dsn=asterisk
  19. readsql=SELECT balance FROM `user_accounts` where id= ${ARG1}
  20.  
  21. //mysql result
  22. SQL result
  23.  
  24. Host: localhost
  25. Database: asterisk
  26. Generation Time: Oct 22, 2012 at 02:00 PM
  27. Generated by: phpMyAdmin 3.5.2.2 / MySQL 5.5.25-log
  28. SQL query: SELECT * FROM `user_accounts` LIMIT 0, 30 ;
  29. Rows: 1
  30.  
  31. id exten pin balance
  32. 1 50 1234 10000
  33.  
  34. //asterisk cli
  35. Executing [751@local:2] Set("SIP/50-00000003", "ID=") in new stack
  36. -- Executing [751@local:3] NoOp("SIP/50-00000003", "the ID is ") in new stack
  37. -- Executing [751@local:4] GotoIf("SIP/50-00000003", "1?auth:getbalance") in new stack
  38. -- Goto (local,751,2)
  39. -- Executing [751@local:2] Set("SIP/50-00000003", "ID=") in new stack
  40. -- Executing [751@local:3] NoOp("SIP/50-00000003", "the ID is ") in new stack
  41. -- Executing [751@local:4] GotoIf("SIP/50-00000003", "1?auth:getbalance") in new stack
  42. -- Goto (local,751,2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement