Back to PhocaGalleryImageFront class

Method getRandomCategory

public static
getRandomCategory
(mixed $parentid, mixed $ordering = ' ORDER BY RAND()')

Method getRandomCategory - Source code

public static function getRandomCategory($parentid, $ordering = ' ORDER BY RAND()')
{
    $db = Factory::getDBO();
    $groups = Factory::getUser()->getAuthorisedViewLevels();
    if (count($groups)) {
        $access = ' AND a.access IN(' . implode(',', $groups) . ')';
    } else {
        $access = '';
    }
    $query = 'SELECT a.id, a.extid' . ' FROM #__phocagallery_categories AS a' . ' WHERE a.parent_id = ' . (int) $parentid . ' AND a.published = 1 ' . $access . $ordering;
    $db->setQuery($query);
    $images = $db->loadObjectList();
    return $images;
}