Back to PhocacartCategoryMultiple class

Method getCategories

public static
getCategories
(mixed $productId, mixed $select = 0)

Method getCategories - Source code

public static function getCategories($productId, $select = 0)
{
    $db = Factory::getDBO();
    if ($select == 1) {
        $query = 'SELECT c.category_id';
    } else {
        if ($select == 2) {
            $query = 'SELECT a.id AS value, a.title AS text';
        } else {
            if ($select == 3) {
                $query = 'SELECT a.id, a.title, a.alias';
            } else {
                $query = 'SELECT a.*';
            }
        }
    }
    $query .= ' FROM #__phocacart_categories AS a' . ' LEFT JOIN #__phocacart_product_categories AS c ON a.id = c.category_id' . ' WHERE c.product_id = ' . (int) $productId;
    $db->setQuery($query);
    if ($select == 1) {
        $tags = $db->loadColumn();
    } else {
        $tags = $db->loadObjectList();
    }
    return $tags;
}