Back to AddUserToGroupCommand class

Method getGroupId

protected int
getGroupId
(mixed $groupName)
Method to get groupId by groupName
Parameters
  • string $groupName name of group
Returns
  • int
Since
  • 4.0.0

Method getGroupId - Source code

/**
 * Method to get groupId by groupName
 *
 * @param   string  $groupName  name of group
 *
 * @return  integer
 *
 * @since   4.0.0
 */
protected function getGroupId($groupName)
{
    $db = Factory::getDbo();
    $query = $db->getQuery(true)->select($db->quoteName('id'))->from($db->quoteName('#__usergroups'))->where($db->quoteName('title') . '= :groupName')->bind(':groupName', $groupName);
    $db->setQuery($query);
    return $db->loadResult();
}