简体   繁体   English

从Joomla数据库获取RS Eevents类别名称

[英]getting RS Eevents category name from Joomla database

I'm trying to get the category details from the joomla database for RSEvents. 我正在尝试从joomla数据库获取RSEvents的类别详细信息。 Can anyone shed any light on why this isn't working: 任何人都可以阐明为什么它不起作用的任何原因:

function _getCategorySlug($value) {
    // Get a db connection.
    $db = JFactory::getDbo();    
    // Create a new query object.
    $query = $db->getQuery(true);    
    // Select all articles for users who have a username which starts with 'a'.
    // Order it by the created date.
    // Note by putting 'a' as a second parameter will generate `#__content` AS `a`
    $query
        ->select($db->quoteName(array('a.*', 'b.id', 'b.ide')))
        ->from($db->quoteName('#__categories', 'a'))
        ->join('INNER', $db->quoteName('#__rseventspro_taxonomy', 'b') 
        . ' ON (' . $db->quoteName('a.id') . ' = ' . $db->quoteName('b.id') . ')')
        ->where($db->quoteName('b.ide') . ' = '.$db->quote($value));     
    // Reset the query using our newly populated query object.
    $db->setQuery($query);   
    // Load the results as a list of stdClass objects (see later for more options on retrieving data).
    $results = $db->loadObjectList();
}

I think this may help you. 我认为这可能对您有帮助。 Using the below function you can get the categories of a particular event. 使用以下功能,您可以获取特定事件的类别。

public function getCategories($id) {
    $db = JFactory::getDbo();
    $query = $db->getQuery(true);

    $query->clear()
        ->select($db->qn('id'))
        ->from($db->qn('#__rseventspro_taxonomy'))
        ->where($db->qn('type').' = '.$db->q('category'))
        ->where($db->qn('ide').' = '.$id);

    $db->setQuery($query);
    return $db->loadColumn();
}

Thanks! 谢谢! That was a great help and got me to where I need (with a little tweaking): 这是一个很大的帮助,并通过一些调整将我带到了我需要的地方:

function getCategories($id) {
    $db = JFactory::getDbo();
    $query = $db->getQuery(true);

    $query->clear()
        ->select($db->qn('id'))
        ->from($db->qn('#__rseventspro_taxonomy'))
        ->where($db->qn('type').' = '.$db->q('category'))
        ->where($db->qn('ide').' = '.$id);
    $db->setQuery($query);
    $categories = $db->loadColumn();
    return implode("_", $categories);
}

Also, would be great to find out what was wrong with my original query to get category's alias from the #__categories table 另外,很高兴找出我原来的查询出了什么问题,以便从#__categories表中获取类别的别名

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM