[英]getting RS Eevents category name from Joomla database
我正在嘗試從joomla數據庫獲取RSEvents的類別詳細信息。 任何人都可以闡明為什么它不起作用的任何原因:
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();
}
我認為這可能對您有幫助。 使用以下功能,您可以獲取特定事件的類別。
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();
}
謝謝! 這是一個很大的幫助,並通過一些調整將我帶到了我需要的地方:
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);
}
另外,很高興找出我原來的查詢出了什么問題,以便從#__categories表中獲取類別的別名
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.