How to check a mysql array for a value?


#1

I am using the extension.conf file.
I am using mysql to get an array - simple - the difficult part:
When I get the array back from mysql - how do i do this ??
if my array structure/values are:
1,222
2,343
3,243
4,459

and i want know the first part of the array - meaning value 1,2,3,4 part and want only to get one of the values of the second part – meaning 222,343,243,459 – how can i do this inside the extension.conf file ??? by choosing say the value 2 in the first part so that it gives me 343.

thanks
mjh


#2

Try agi for this. If you can use perl please use the Asterisk::AGI which can be found here:
search.cpan.org/~jamesgol/asteri … isk/AGI.pm


#3

Hi mjh5598!

This is how I do a DB search from the dialplan:

DB Table = my_table

[code]id | my_value


1 | 222
2 | 343
3 | 243
4 | 459
[/code]

exten => s,n,MYSQL(Connect connid ${DB_HOST} ${DB_USER} ${DB_USER_PWD} ${DB_NAME}) exten => s,n,MYSQL(Query resultid ${connid} SELECT\ id\,my_value\ FROM\ my_table\ WHERE\ searched_id_number=2) exten => s,n,MYSQL(Fetch fetchid ${resultid} result_id result_my_value) exten => s,n,MYSQL(Clear ${resultid}) exten => s,n,MYSQL(Disconnect ${connid})
After this you will have your result in the variable:

Hope this helps you!