• Idefisk
  • Tools
  • Tutorials
  • Reviews
  • VoIP Providers
  • Archives
ZOIPER softphone
Back to Tutorials

6.1.1.10. DB() - get (dialplan function) - NEW

1. DB() - this function allows you to retrieve or store a value in the Asterisk’s database.

In this tutorial we will show you how to retrieve a value from the Asterisk database and how this function will replace the old DBget application.

NOTE:Information about the Asterisk functions could be obtained by typing the show functions command.

Information about a particular function could be obtained by typing the show function <function name> on the Asterisk CLI command.

NOTE: In Asterisk versions 1.2 and up there are several applications which are mark as deprecated and which are no longer supported.

These applications will now become functions and these functions will be used in combination with the Set application.

You have to know that their functionality will be the same, but with a different syntax.

The DB() function is one of those functions which will replace the old applications. In this tutorial we will show you its syntax and possible usage.

Check out the old syntax of the DBget application here
 


Syntax:

Set(variable=${DB(family/key)})

 


List of the possible options

variable - The new variable, where the value retrieved from the database will be stored
family/key - from which family/key the value to be retrieved.

 


Purpose and usage

The purpose of this function is to allow you to get a value from the Asterisk’s database and to set it to an arbitrary variable. This function has absolutely the same effect as the CLI command - database get <family> <key>.

However, it gives you more flexibility, because you could manage the Asterisk’s database in your extensions.conf file.

Below, we will give you an example.

 


Prerequisites

To use this application you need a working Asterisk PBX with registered users in iax.conf, sip.conf or mgcp.conf(It depends on which protocol you would like to use) and made extensions. We are using Asterisk version1.2.1.

To see how the application works we recommend you to use our IAX softphone Idefisk. You could download it from here. Please also read our tutorial to learn how to configure it to work with Asterisk PBX.

 


Asterisk PBX configurations

iax.conf Configurations

We need to create one user in the iax.conf file. This is because we are going to use the IAX2 protocol. If you want to use other protocol, such as SIP or MGCP, you have to do the configurations below respectively in sip.conf or mgcp.conf.

iaxoneuser.jpg

So, we have registered the user user1

Type=friend means that this user can make and receive calls. Host=dynamic means that the IP is not static but dynamic through a DHCP server. Allow=all means that the line which this user will use, could support all audio codecs. Context=test - this shows that this user is working with the extensions in this context of the configuration file extensions.conf.


extensions.conf Configurations

Now lets take a look at the extensions.conf file.

extsetdbget1.jpg

On the picture above you could see our extensions.conf file.

In this example, when somebody dials 200, the call will be answered by the Answer application.

The next executed extension will be the one which contains the Set application. As arguments in its brackets we have set NEWVAR=${DB(data/test)}. NEWVAR is the variable, where we are going to store the value, which we will retrieve from the Asterisk database.
DB is the name of the function, then we have data, which is the family in the Asterisk’s database and test, which is the key.

We will use the NoOp application to see the returned value. We have to put as argument the variable, used in the previous line - ${NEWVAR}. In our case it will return 122. You could see this on the screenshot from our CLI

NOTE: The function DB is case sensitive. You always have to write it in your dialplans with capital letters.

You can verify that this is the correct value, by entering the command database show on the CLI of your Asterisk PBX system.

In order to be sure that the Asterisk PBX will hang up the line, when the conversation is over, it is a good idea to use the Hangup application.

 


2. Screenshots of what you could see on the CLI of the Asterisk PBX

clidbput1.jpg

 


3. Additional information

For more information about extensions.conf you can check here.
For more information about iax.conf you can check here.

This application is tested with our IAX softphone Idefisk. You can download it from here. For more information about this softphone please read our tutorial.

If you would like to test this application with the SIP channel you can read our tutorials about the SIP Softphones to learn how to configure them to work with Asterisk PBX

More information about the Set application could be found here

 


4. Uploaded files

DB function configuration files (DBput and DBget) - configuration files

 


5. Similar dialplan functions

DB() - put

 

 
User Comments
viagra for sale canadian (tamikawarby8327 at adult-work dot info)
27 June 2020 18:22:11
viagra for sale canadian http://viacheapusa.com/
Wissam (xm4rstqbs1 at gmail dot com)
20 December 2015 21:34:58
If you are looking for a PBX suiotlon based on SIP. Sipgate allow up to 15 calls to be handled on a single phone number.We can supply anywhere in the UK a system that gives you IVR, voicemail, call transfer, and remote user log in.. Head office in Manchester and remote users logged on anywhere on Earth.The system can also record all calls.a310 for 1000 Minutes and NO line rental !!!! from Sipgate.co.uk http://ynvnxnzt.com [url=http://pojubjr.com]pojubjr[/url] [link=http://eprtab.com]eprtab[/link]
 
Add Comment
Name:
Email:
Comment:
In order to prevent automatic posting on our website, we kindly request you to type in the number you see in the picture below.
Image Verification:
 

Latest Headlines:

  • T.38 faxing with Zoiper 2.15 is now easier than ever
    section: voip software
  • Asterisk 1.4.21 Released
    section: Asterisk
  • Asterisk 1.4.20 Released
    section: Asterisk
  • Asterisk 1.4.20-rc2 Released
    section: Asterisk
  • Asterisk 1.4.20-rc1 Now Available
    section: Asterisk
  • News Archives (older news)

Latest Tutorials:

  • Sending Fax from Zoiper to Zoiper using T.38
    added 08/Dec/2008 18:16
  • VMAuthenticate (dialplan application)
    added 01/Mar/2008 15:57
  • Siptronic ST-530
    added 06/Nov/2007 17:57
  • Siemens C455 IP hardphone
    added 05/Nov/2007 10:24
  • Zoiper
    added 22/Oct/2007 17:53

Latest Comments:

  • https://laylo.com/laylo-jkuj6lb https:/...
    tutorial: Read (dialplan application)
  • https://gist.github.com/Ling-Yuxiu http...
    tutorial: asterisk.conf
  • http://www.ci2.cgai.udg.mx/sites/default...
    tutorial: SIP with NAT or Firewalls
  • ttps://gist.github.com/maziya408-pixel/4...
    tutorial: SIP with NAT or Firewalls
  • https://gist.github.com/taug3978-dev/940...
    tutorial: SIP with NAT or Firewalls
 
contact us at: support@asteriskguru.com - asterisKGuru.com © all rights reserved   |   *asterisk is registered trademark of © Digium™