Back to ContentHelper class

Method getLanguageId

public static int
getLanguageId
(mixed $langCode)
Gets the associated language ID
Parameters
  • string $langCode The language code to look up
Returns
  • int The language ID
Since
  • 3.1
-
  • CmsHelper::getLanguage() is the preferred method.
Class: ContentHelper
Project: Joomla

Method getLanguageId - Source code

/**
 * Gets the associated language ID
 *
 * @param   string  $langCode  The language code to look up
 *
 * @return  integer  The language ID
 *
 * @since   3.1
 * @note    CmsHelper::getLanguage() is the preferred method.
 */
public static function getLanguageId($langCode)
{
    $db = Factory::getDbo();
    $query = $db->getQuery(true)->select($db->quoteName('lang_id'))->from($db->quoteName('#__languages'))->where($db->quoteName('lang_code') . ' = :language')->bind(':language', $langCode);
    $db->setQuery($query);
    return $db->loadResult();
}