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


PHP SearchHelper::getTables方法代码示例

本文整理汇总了PHP中SearchHelper::getTables方法的典型用法代码示例。如果您正苦于以下问题:PHP SearchHelper::getTables方法的具体用法?PHP SearchHelper::getTables怎么用?PHP SearchHelper::getTables使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SearchHelper的用法示例。


在下文中一共展示了SearchHelper::getTables方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onSearchGetAllThreads

 function onSearchGetAllThreads($num, $tId = 0, $orderType = 'ASC')
 {
     $orderType = strtoupper($orderType);
     $tables = SearchHelper::getTables('thread');
     $tableNum = count($tables);
     $res = $data = $_tableInfo = array();
     $minTid = $maxTid = 0;
     for ($i = 0; $i < $tableNum; $i++) {
         $_threads = $this->_getAllThreads(DB::table($tables[$i]), $num, $tId, $orderType);
         if ($_threads['data']) {
             if (!$data) {
                 $data = $_threads['data'];
             } else {
                 $data = $data + $_threads['data'];
             }
         }
         if ($orderType == 'DESC') {
             if (!$minTid) {
                 $minTid = $_threads['minTid'];
             }
             if ($minTid > $_threads['minTid']) {
                 $minTid = $_threads['minTid'];
             }
             $_tableInfo['minTids'][] = array('current_index' => $i, 'minTid' => $_threads['minTid']);
         } else {
             if ($maxTid < $_threads['maxTid']) {
                 $maxTid = $_threads['maxTid'];
             }
             $_tableInfo['maxTids'][] = array('current_index' => $i, 'maxTid' => $_threads['maxTid']);
         }
     }
     $_threadNum = 0;
     if ($orderType == 'DESC') {
         if ($minTid) {
             for ($j = $tId - 1; $j >= $minTid; $j--) {
                 if ($j == 0) {
                     break;
                 }
                 if (array_key_exists($j, $data)) {
                     $_threadNum++;
                     $res['minTid'] = $j;
                     $res['data'][$j] = $data[$j];
                     if ($_threadNum == $num) {
                         break;
                     }
                 }
             }
             if (!$res['minTid']) {
                 $res['minTid'] = $minTid;
             }
         }
     } else {
         if ($maxTid) {
             for ($j = $tId + 1; $j <= $maxTid; $j++) {
                 if (array_key_exists($j, $data)) {
                     $_threadNum++;
                     $res['data'][$j] = $data[$j];
                     $res['maxTid'] = $j;
                     if ($_threadNum == $num) {
                         break;
                     }
                 }
             }
             if (!$res['maxTid']) {
                 $res['maxTid'] = $maxTid;
             }
         }
     }
     if ($res['data']) {
         $_tableInfo['tables'] = $tables;
         $_tIds = array();
         $authors = $gfIds = array();
         foreach ($res['data'] as $tId => $thread) {
             $_tIds[$thread['postTableId']][] = $tId;
             $authors[$thread['authorId']][] = $thread['tId'];
             if ($thread['isGroup']) {
                 $gfIds[$thread['fId']] = $thread['fId'];
             }
         }
         if ($_tIds) {
             $guestPerm = SearchHelper::getGuestPerm($gfIds);
             // GuestPerm
             $threadPosts = SearchHelper::getThreadPosts($_tIds);
             foreach ($res['data'] as $tId => $v) {
                 $res['data'][$tId]['pId'] = $threadPosts[$tId]['pId'];
                 if (in_array($v['fId'], $guestPerm['allowForumIds'])) {
                     $res['data'][$tId]['isPublic'] = true;
                 } else {
                     $res['data'][$tId]['isPublic'] = false;
                 }
             }
         }
         $authorids = array_keys($authors);
         if ($authorids) {
             $banuids = $uids = array();
             $sql = sprintf('SELECT uid, username, groupid FROM %s WHERE uid IN (%s)', DB::table('common_member'), implode($authorids, ', '));
             $query = DB::query($sql);
             while ($author = DB::fetch($query)) {
                 $uids[$author['uid']] = $author['uid'];
                 if ($author['groupid'] == 4 || $author['groupid'] == 5) {
//.........这里部分代码省略.........
开发者ID:pan289091315,项目名称:Discuz,代码行数:101,代码来源:my.php


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