I’d like to know how to connect my dial plan to a mysql database.
The goal is to have callers who reach a particular ext have to enter a PIN in order to continue to the next priority.
I’m using Asterisk@Home version 2.5 I don’t have a programming background so most of the self help sites I see are goobly gook to me. Please understand.
Example
exten => 11,1,Background(custom/GreetingSaysEnterPIN)
exten => 11,2,Customer enters PIN listed in PIN_NUm mysql database.
exten => 11,3,If PIN is available call goes to priority 4. If invalid PIN is entered, caller gets “Invalid account” recording.
Hi, Ian,
The answer is no, it is not an existing database. I was thinking that after I figure out how to connect to a database, I could then create it and connect to it.
The database does not need to be sql. I just thought msql because I keep seeing references to making databases using mysql. From what I have read they are supposed to be faster, better etc, etc.
I would be open to using the internal database if I can figure out how to use it.
am800,
I did consider the example that you gave. However, I would like to have individual PINs for callers. I do not want to have the same PIN for every caller.
Thanks for the suggestion
I do have a complete system using the internal atabase that has usernumbers and pins that works with disa by changing the context of the call and allowing them to dial out. It is set up via a web gui to ease the entry of pins.
[code]09:12:06@forge> show application MYSQL
09:12:07@forge>
-= Info about application ‘MYSQL’ =-
[Synopsis]
Do several mySQLy things
[Description]
MYSQL(): Do several mySQLy things
Syntax:
MYSQL(Connect connid dhhost dbuser dbpass dbname)
Connects to a database. Arguments contain standard MySQL parameters
passed to function mysql_real_connect. Connection identifer returned
in ${var}
MYSQL(Query resultid ${connid} query-string)
Executes standard MySQL query contained in query-string using established
connection identified by ${connection_identifier}. Result of query is
is stored in ${var}.
MYSQL(Fetch fetchid ${resultid} var1 var2 … varN)
Fetches a single row from a result set contained in ${result_identifier}.
Assigns returned fields to ${var1} … ${varn}. ${fetchid} is set TRUE
if additional rows exist in result set.
MYSQL(Clear ${resultid})
Frees memory and datastructures associated with result set.
MYSQL(Disconnect ${connid})
Disconnects from named connection to MySQL.
On exit, always returns 0. Sets MYSQL_STATUS to 0 on success and -1 on error.[/code]