Help Required --> Using MySQL command in DialPlan


#1

Hi
I am trying to use MySQL command in extensions.conf. I want to ask following:

  1. I am running Asterisk on one Machine and MySQL Database is another Linux PC in the same network. Can I access this Database using IP of that PC. In my other PHP applications, I can access the Database with IP.

  2. We don’t have any password for that Database. So how to use the MySQL command to connect to the database. For instance:

MYSQL(Connect connid dbserver dbuser dbpass dbname)

Will the following work?

MYSQL(Connect connid IP dbuser “” dbname)
or it is wrong.
Please guide
Thanks


#2

Yes, this is possible:

voip-info.org/wiki-Asterisk+cmd+MYSQL

[quote=“Asterisk Wiki”]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 ${connid}

MYSQL(Query resultid ${connid} query-string)

Executes standard MySQL query contained in query-string using established connection identified by ${connid}. Result of query is stored in ${resultid}.

MYSQL(Fetch fetchid ${resultid} var1 var2 … varN)

If any rows are available to select, ${fetchid} is set to 1 and a single row is fetched from a result set contained in ${resultid}. The return fields are assigned to ${var1}, ${var2} … ${varN} respectively.

If no rows are left to select, ${fetchid} is set to 0 and ${var1}, ${var2} … ${varN} remain unchanged.

MYSQL(Clear ${resultid})

Frees memory and data structures associated with result set.

MYSQL(Disconnect ${connid})

Disconnects from named connection to MySQL. [/quote]