Back to OrderingField class

Method getQuery

protected \Joomla\Database\DatabaseQuery
getQuery
()
Builds the query for the ordering list.
Returns
  • \Joomla\Database\DatabaseQuery The query for the ordering form field
Since
  • 3.2
Class: OrderingField
Project: Joomla

Method getQuery - Source code

/**
 * Builds the query for the ordering list.
 *
 * @return  DatabaseQuery  The query for the ordering form field
 *
 * @since   3.2
 */
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;
}