本文整理汇总了PHP中SearchHelper::preGetThreads方法的典型用法代码示例。如果您正苦于以下问题:PHP SearchHelper::preGetThreads方法的具体用法?PHP SearchHelper::preGetThreads怎么用?PHP SearchHelper::preGetThreads使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchHelper
的用法示例。
在下文中一共展示了SearchHelper::preGetThreads方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getThreads
function getThreads($tIds, $isReturnPostId = true)
{
global $_G;
$tables = array();
$infos = unserialize($_G['setting']['threadtable_info']);
if ($infos) {
foreach ($infos as $id => $row) {
$suffix = $id ? "_{$id}" : '';
$tables[] = 'forum_thread' . $suffix;
}
} else {
$tables = array('forum_thread');
}
$tableNum = count($tables);
$res = $data = $_tableInfo = array();
for ($i = 0; $i < $tableNum; $i++) {
$_threads = SearchHelper::preGetThreads(DB::table($tables[$i]), $tIds);
if ($_threads) {
if (!$data) {
$data = $_threads;
} else {
$data = $data + $_threads;
}
if (count($data) == count($tIds)) {
break;
}
}
}
if ($isReturnPostId) {
$threadIds = array();
foreach ($data as $tId => $thread) {
$postTableId = $thread['postTableId'];
$threadIds[$postTableId][] = $tId;
}
$threadPosts = SearchHelper::getThreadPosts($threadIds);
foreach ($data as $tId => $thread) {
$data[$tId]['pId'] = $threadPosts[$tId]['pId'];
}
}
return $data;
}
示例2: _removeThreads
function _removeThreads($tIds)
{
global $_G;
$tables = array();
$infos = unserialize($_G['setting']['threadtable_info']);
if ($infos) {
foreach ($infos as $id => $row) {
$suffix = $id ? "_{$id}" : '';
$tables[] = 'forum_thread' . $suffix;
}
} else {
$tables = array('forum_thread');
}
$tableThreads = array();
foreach ($tables as $table) {
$_threads = SearchHelper::preGetThreads(DB::table($table), $tIds);
$tableThreads[$table] = $_threads;
}
foreach ($tableThreads as $table => $threads) {
$_tids = $_threadIds = array();
foreach ($threads as $thread) {
$_tids[] = $thread['tId'];
$postTable = $thread['postTableId'] ? '-' . $thread['postTableId'] : '';
$_threadIds[$postTable][] = $thread['tId'];
}
if ($_tids) {
$sql = sprintf('DELETE FROM %s WHERE tid IN (%s)', DB::table($table), implode(',', $_tids));
DB::query($sql);
}
if ($_threadIds) {
foreach ($_threadIds as $postTable => $_tIds) {
if ($_tIds) {
$sql = sprintf('DELETE FROM %s WHERE tid IN (%s)', DB::table('forum_post' . $postTable), implode(',', $_tIds));
DB::query($sql);
}
}
}
}
return true;
}
示例3: _removeThreads
function _removeThreads($tIds, $isRecycle = false)
{
$tables = SearchHelper::getTables('thread');
$tableThreads = array();
foreach ($tables as $table) {
$_threads = SearchHelper::preGetThreads(DB::table($table), $tIds);
$tableThreads[$table] = $_threads;
}
foreach ($tableThreads as $table => $threads) {
$_tids = $_threadIds = array();
foreach ($threads as $thread) {
$_tids[] = $thread['tId'];
$postTable = $thread['postTableId'] ? '_' . $thread['postTableId'] : '';
$_threadIds[$postTable][] = $thread['tId'];
}
if ($_tids) {
if ($isRecycle) {
$sql = sprintf('UPDATE %s SET displayorder = -1 WHERE tid IN (%s)', DB::table($table), implode(',', $_tids));
DB::query($sql);
continue;
}
$sql = sprintf('DELETE FROM %s WHERE tid IN (%s)', DB::table($table), implode(',', $_tids));
DB::query($sql);
foreach ($_threadIds as $postTable => $_tIds) {
if ($_tIds) {
$sql = sprintf('DELETE FROM %s WHERE tid IN (%s)', DB::table('forum_post' . $postTable), implode(',', $_tIds));
DB::query($sql);
}
}
}
}
return true;
}