protected function getQuery()
{
$categoryId = (int) $this->form->getValue('catid');
$ucmType = new UCMType();
$ucmRow = $ucmType->getType($ucmType->getTypeId($this->contentType));
$ucmMapCommon = json_decode($ucmRow->field_mappings)->common;
if (\is_object($ucmMapCommon)) {
$ordering = $ucmMapCommon->core_ordering;
$title = $ucmMapCommon->core_title;
} elseif (\is_array($ucmMapCommon)) {
$ordering = $ucmMapCommon[0]->core_ordering;
$title = $ucmMapCommon[0]->core_title;
}
$db = Factory::getDbo();
$query = $db->getQuery(true);
$query->select([$db->quoteName($ordering, 'value'), $db->quoteName($title, 'text')])->from($db->quoteName(json_decode($ucmRow->table)->special->dbtable))->where($db->quoteName('catid') . ' = :categoryId')->order($db->quoteName('ordering'))->bind(':categoryId', $categoryId, ParameterType::INTEGER);
return $query;
}