当前位置: 首页>>代码示例>>PHP>>正文


PHP CKunenaTools::reCountBoardsRecursion方法代码示例

本文整理汇总了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.");
     }
 }
开发者ID:kaantunc,项目名称:MYK-BOR,代码行数:34,代码来源:class.kunena.php


注:本文中的CKunenaTools::reCountBoardsRecursion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。