SQL command

In this command, an API extension run an SQL command in the database where the SQL call extension connected.

Command example usage:

In this example, a simple vote counting script is implemented. By pressing 1, 2 or 3, the caller can choose between colors. When you press a button, the SQL script runs and the value of the votes in the database is updated. At the end of the call, we retrieve the current status from the database, and read it to the caller.

<?xml version="1.0"?>
<Response>
<UserInput timeout="6" repeat="false">
<InitialCommands>
<Speak>What is your favourite colour? Press 1 for red, press 2 for blue, 3 for green</Speak>
</InitialCommands>
<Inputs>
     <Input key="1">
	<Speak>You have selected red</Speak>
	<SQL>
	    INSERT INTO votelog (caller,dialed,datereceived,color) VALUES ('$caller' ,'$dialed','$datecreated','red');
	    UPDATE voteresult SET red=red+1;
	</SQL>
    </Input>
    <Input key="2">
       <Speak>You have selected blue</Speak>
	<SQL>
	    INSERT INTO votelog (caller,dialed,datereceived,color) VALUES ('$caller' ,'$dialed','$datecreated','blue');
	    UPDATE voteresult SET blue=blue+1;
	</SQL>
    </Input>
    <Input key="3">
	<Speak>You have selected green</Speak>
	<SQL>
	    INSERT INTO votelog (caller,dialed,datereceived,color) VALUES ('$caller' ,'$dialed','$datecreated','green');
	    UPDATE voteresult SET green=green+1;
	</SQL>
    </Input>
    <Input key="default">
	<BackKey/>
    </Input>
</Inputs>
</UserInput>
<Speak>Thank you for voting. Here are the results</Speak>
<SQL>select Concat("Red ",red,", blue ",blue,", green ",green) from voteresult limit 1;</SQL>
<Hangup></Hangup>
</Response>

More information