protected \Joomla\Database\DatabaseQuery
processQuery
(mixed $conditions, mixed $filters, mixed $defaults)
/**
* Method to process the query from form.
*
* @param array $conditions The conditions from the form.
* @param string $filters The columns to filter.
* @param array $defaults The defaults value to set if condition is empty.
*
* @return DatabaseQuery The query object.
*
* @since 3.5
*/
protected function processQuery($conditions, $filters, $defaults)
{
// Get the database object.
$db = Factory::getDbo();
// Get the query object
$query = $db->getQuery(true);
// Select fields
$query->select($conditions['select']);
// From selected table
$query->from($conditions['from']);
// Join over the groups
if (!empty($conditions['join'])) {
$query->join('LEFT', $conditions['join']);
}
// Where condition
if (!empty($conditions['where'])) {
$query->where($conditions['where']);
}
// Group by
if (!empty($conditions['group'])) {
$query->group($conditions['group']);
}
// Process the filters
if (\is_array($filters)) {
$html_filters = Factory::getApplication()->getUserStateFromRequest($this->context . '.filter', 'filter', array(), 'array');
foreach ($filters as $k => $value) {
if (!empty($html_filters[$value])) {
$escape = $db->quote($db->escape($html_filters[$value]), false);
$query->where("{$value} = {$escape}");
} elseif (!empty($defaults[$value])) {
$escape = $db->quote($db->escape($defaults[$value]), false);
$query->where("{$value} = {$escape}");
}
}
}
// Add order to query
if (!empty($conditions['order'])) {
$query->order($conditions['order']);
}
return $query;
}