if(!defined('IN_DISCUZ'))
{
exit('Access Denied');
}
$strsql_forum_fp="select fid from forum_forum where fid !=14 and status=1 and type !='group' order by fid asc ";//版块循环,取出来
$result_forum_fp=DB::fetch_all($strsql_forum_fp);
if($result_forum_fp)
{
foreach($result_forum_fp as $key =>$val)
{
$strsql_thread_each_1="select tid from forum_thread_index_20150602 where fid=".$val['fid']." order by tid desc limit 0,1";//查找分表中这一板块的最大 tid
$result_thread_each_1=DB::fetch_first($strsql_thread_each_1);
if( !$result_thread_each_1['tid'])
{
$result_thread_each_1['tid']=1;
}
$strsql_thread_each_2="select tid,fid,sortid,author,authorid,subject,dateline,special,heats,stamp from forum_thread where fid=".$val['fid']." and tid >".$result_thread_each_1['tid']." and hidden=0 order by tid desc limit 0,50"; //获取50条大于分表中取出的最大 tid
$result_thread_each_2=DB::fetch_all($strsql_thread_each_2);
if($result_thread_each_2)
{
foreach($result_thread_each_2 as $key => $val)
{
$strsql_check="SELECT tid FROM forum_thread_index_20150602 where fid=".$val['fid']." and tid =".$val['tid']; //如果分表中有重复的便停止运行计划任务
$result_check=DB::fetch_first($strsql_check);
if( !$result_check )
{
$strsql_thread_each_3="select tid,message from forum_post where tid =".$val['tid']." and invisible = 0 and first=1 limit 0,1";
$result_thread_each_3=DB::fetch_first($strsql_thread_each_3);
if( $result_thread_each_3)
{
$strsql_thread_each_4="select avatarstatus from common_member where uid=".$val['authorid']." limit 0,1";
$result_thread_each_4=DB::fetch_first($strsql_thread_each_4);
if($val['sortid'] == 23)
{
$strsql_thread_each_5="select archy_zj_9_23 as jg,archy_dz_9_23 as dz,archy_lxr_9_23 as lxr from forum_optionvalue23 where tid=".$val['tid']." limit 0,1";
$result_thread_each_5=DB::fetch_first($strsql_thread_each_5);
}
if($val['sortid'] == 24)
{
$strsql_thread_each_5="select tzsc_zrjg_24 as jg,tzsc_dzxq_24 as dz,tzsc_lxr_24 as lxr from forum_optionvalue24 where tid=".$val['tid']." limit 0,1";
$result_thread_each_5=DB::fetch_first($strsql_thread_each_5);
}
$strsql_insert_new = DB::insert('forum_thread_index_20150602',array('tid'=>$val['tid'],'fid'=>$val['fid'],'sortid'=>$val['sortid'],'author'=>$val['author'],'authorid'=>$val['authorid'],'subject'=>$val['subject'],'dateline'=>$val['dateline'],'special'=>$val['special'],'heats'=>$val['heats'],'stamp'=>$val['stamp'],'avatarstatus'=>$result_thread_each_4['avatarstatus'],'message'=>$result_thread_each_3['message'],'jg'=>$result_thread_each_5['jg'],'dz'=>$result_thread_each_5['dz'],'lxr'=>$result_thread_each_5['lxr']));
unset($result_thread_each_3);
unset($result_thread_each_4);
unset($result_thread_each_5);
}
}
else
{
unset($result_thread_each_1);
unset($result_thread_each_2);
exit();
}
}
}
unset($result_thread_each_1);
unset($result_thread_each_2);
}
}
unset($result_forum_fp); |