How to write a full custom SQL query in Chronoforms

Discover how to easily run any custom SQL query on your Joomla or WordPress database using ChronoForms8.

In this tutorial we will show you how to use your own full custom SQL query as a data source for any Chronoforms view, this technique can be implemented in Chronoforms version 6,7 or 8

First, add a PHP action to your form and paste this code:

// Import Joomla's database classes
use Joomla\CMS\Factory;
use Joomla\CMS\Table\Table;

// Get the database connection
$db = Factory::getDbo();

// Create a new query object
$query = $db->getQuery(true);

// Execute the query
$db->setQuery("SELECT * FROM #__chronoforms8");

// Load the results as an array of objects
$results = $db->loadAssocList();

return $results;

Now you may customize the SQL query to anything you like, and use {var:php_action_name} as your data source in Dropdown, Checkboxes, Radios or Table view or any other lists which need a data source.

Category: ChronoForms v8

VPS & Email Hosting 20% discount
hostinger