Back to UCMContent class

Method getPrimaryKey

public int
getPrimaryKey
(mixed $typeId, mixed $contentItemId)
Get the value of the primary key from #__ucm_base
Parameters
  • int $typeId The ID for the type
  • int $contentItemId Value of the primary key in the legacy or secondary table
Returns
  • int The integer of the primary key
Since
  • 3.1
Class: UCMContent
Project: Joomla

Method getPrimaryKey - Source code

/**
 * Get the value of the primary key from #__ucm_base
 *
 * @param   integer  $typeId         The ID for the type
 * @param   integer  $contentItemId  Value of the primary key in the legacy or secondary table
 *
 * @return  integer  The integer of the primary key
 *
 * @since   3.1
 */
public function getPrimaryKey($typeId, $contentItemId)
{
    $db = Factory::getDbo();
    $query = $db->getQuery(true)->select($db->quoteName('ucm_id'))->from($db->quoteName('#__ucm_base'))->where([$db->quoteName('ucm_item_id') . ' = :itemId', $db->quoteName('ucm_type_id') . ' = :typeId'])->bind(':itemId', $contentItemId, ParameterType::INTEGER)->bind(':typeId', $typeId, ParameterType::INTEGER);
    $db->setQuery($query);
    return $db->loadResult();
}