SQL Query Action helps in executing SQL queries on submission of a form. Database on which query will be executed of, either the site on which the form  is or some other sites.

Purpose of SQL Query Action:


If you want to -


Insert Posted data into database.


Update Existing data of database.


Delete Matched data in your database.


[span style="text-decoration: underline;"]SQL Query action can be configured as :[/span]


Step 1:

SQL Query is a paid action and by-default it is disabled.You have to go to plugin manager and enable the plugin SQL Query of Jxiforms type for SQL Query action.


Enable SQL Query Plugin JXiForms


Step 2:

Now go to Actions section of JXiForms to create SQL Query action.


Create SQL Query Action JXiForms


Step 3:

When you click on Next you will go to the action Configuration Screen, looks like:


Configure JXiForms To Run SQL Query


Step 4:

Enter the details asked in the SQL Query action screen.


[span style="text-decoration: underline;"]Under Details section:[/span]



  • Title : Title of the action.

  • Published : It indicates the status of the action (published or not).


Description : Description of the action.


Select Form : Here you can select the form list on which you want to apply this action.


Require Approval : This parameter lets you decide whether to put approval request before executing query or not. If you set this to YES then no query will be executed unless you approve it. If you set this to NO then email will not be sent before executing query.


[span style="text-decoration: underline;"]Under Parameters Section:[/span]



  • Use Default Database: Database on which query will be executed is of current site or of some other.

  • Query(required): Query to be Executed.


Spacify following in case if database is not default.



  • Database Host: Hostname of database.

  • Database Username: Username of the database.

  • Password: Password for the specified user of database.

  • Database Name: Database Name on which query will be executed.

  • Table Prefix: Prefix for tables.


Example: As shown in above action configuration, Suppose you want to make your own Address book, For this:


Run SQL Query on Form Submit JXiForms



    [ul]
  • You have to create a form (Form For Address Book, as in Select Form field).

  • Select Yes Default Database, If your are going to use current site’s database, no need for specifying username and password.

  • If you Select No then you have to specify all fields as mentioned above in Parameter Section.

  • Query must be supplied in both of the cases(default and non-default database) and structure is as follows:
    [ul]
    [li]INSERT INTO `#__address_book` (name, email, address) VALUES ([[name]], [[email]], [[address]]);

  • Here name, email, address in VALUES are the name of html elements of your form where the user enters name, email, address respectively.


[/li]
  • Now when a user submits the form of address book, the values will be inserted into specified database table automatically.

  • [/ul]
    [/ul]