本文整理匯總了PHP中CKunenaTools::reCountBoardsRecursion方法的典型用法代碼示例。如果您正苦於以下問題:PHP CKunenaTools::reCountBoardsRecursion方法的具體用法?PHP CKunenaTools::reCountBoardsRecursion怎麽用?PHP CKunenaTools::reCountBoardsRecursion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CKunenaTools
的用法示例。
在下文中一共展示了CKunenaTools::reCountBoardsRecursion方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: reCountBoards
function reCountBoards()
{
$kunena_db =& JFactory::getDBO();
include_once KUNENA_PATH_LIB . DS . 'kunena.db.iterator.class.php';
// Reset category counts as next query ignores empty categories
$kunena_db->setQuery("UPDATE #__fb_categories SET numTopics=0, numPosts=0");
$kunena_db->query();
check_dberror("Unable to reset category post counts.");
// Update category post count
$kunena_db->setQuery("INSERT INTO #__fb_categories (id, numTopics, numPosts, id_last_msg, time_last_msg)" . " SELECT c.id, SUM( m.parent=0 ), SUM( m.parent>0 ), MAX( m.id ), MAX( m.time )" . " FROM #__fb_messages as m" . " INNER JOIN #__fb_categories AS c ON c.id=m.catid" . " WHERE m.catid>0 AND m.hold=0" . " GROUP BY catid " . " ON DUPLICATE KEY UPDATE numTopics=VALUES(numTopics), numPosts=VALUES(numPosts), id_last_msg=VALUES(id_last_msg), time_last_msg=VALUES(time_last_msg)");
$kunena_db->query();
check_dberror("Unable to update categories post count.");
// Load categories to be counted
$kunena_db->setQuery("SELECT id, parent, published, numTopics, numPosts, id_last_msg, time_last_msg FROM #__fb_categories");
$cats = $kunena_db->loadObjectList('id');
check_dberror("Unable to load categories.");
foreach ($cats as $c) {
if (isset($cats[$c->parent])) {
$cats[$c->parent]->children[] = $c->id;
} else {
$cats[0]->children[] = $c->id;
}
}
CKunenaTools::reCountBoardsRecursion($cats, 0);
// now back to db
foreach ($cats as $c) {
if (!isset($c->id)) {
continue;
}
$kunena_db->setQuery("UPDATE #__fb_categories SET" . " numTopics=" . intval($c->numTopics) . ", numPosts=" . intval($c->numPosts) . ", id_last_msg=" . intval($c->id_last_msg) . ", time_last_msg=" . intval($c->time_last_msg) . " WHERE id=" . intval($c->id));
$kunena_db->query();
check_dberror("Unable to update categories.");
}
}