贾玉华
PW 8.7内测组
PW 8.7内测组
  • 发帖数1947
  • 铜币13439两
  • 威望2307点
  • 贡献1点
  • 注册日期2011-02-15
  • 最后登录2018-01-13
  • 社区居民
  • 忠实会员
  • 最爱沙发
阅读:4445回复:21

[求助]关于拆分后的帖子无法编辑的解决思路探讨

楼主#
更多 发布于:2017-03-04 12:56
系统提示:关于phpwind产品的学习与交流已经迁移到阿里云论坛,请访问这里:https://bbs.aliyun.com/fourms.php?m=bbs&cateid=403
拆分后的帖子,如果源版块和目标版块不同,编辑帖子会提示“帖子id非法”。
图片:1.jpg

如图,帖子pid19257原是主题tid2730里面的帖子,位于版块fid21;
拆分后,变成主题tid3256的帖子(目标版块fid48),然而,版块id没有变化。

图片:2.jpg

如图,编辑拆分后的帖子,提示“帖子ID非法”,网址如上;
如果修改版块的fid值48为21(也就是数据表里的正确数据),则可以正常编辑。
说明拆分操作时,没有正确更新帖子所该在的版块。

我想到的解决思路是这样:
因为在拆分操作时会要求输入主题的tid(模板文件里是$splitid),我们可以要求增加输入目标主题所在的版块fid(可以在模板中记录为$splifid),最后由 masingle.php一并把$splitid 和$splifid 更新到pw_posts表就可以解决了。

拆分管理模板示意如下:
图片:3.jpg


因为不懂代码,经尝试没能成功,所以只能做到这里,希望大家能帮助解决!
[贾玉华于2017-03-05 11:23编辑了帖子]
贾玉华
PW 8.7内测组
PW 8.7内测组
  • 发帖数1947
  • 铜币13439两
  • 威望2307点
  • 贡献1点
  • 注册日期2011-02-15
  • 最后登录2018-01-13
  • 社区居民
  • 忠实会员
  • 最爱沙发
沙发#
发布于:2017-03-04 12:57
系统提示:关于phpwind产品的学习与交流已经迁移到阿里云论坛,请访问这里:https://bbs.aliyun.com/fourms.php?m=bbs&cateid=403
@元芳 帮忙看下@孤独之虎 @bink1224 @魅柒
[贾玉华于2017-03-08 21:04编辑了帖子]
贾玉华
PW 8.7内测组
PW 8.7内测组
  • 发帖数1947
  • 铜币13439两
  • 威望2307点
  • 贡献1点
  • 注册日期2011-02-15
  • 最后登录2018-01-13
  • 社区居民
  • 忠实会员
  • 最爱沙发
板凳#
发布于:2017-03-04 13:02
系统提示:关于phpwind产品的学习与交流已经迁移到阿里云论坛,请访问这里:https://bbs.aliyun.com/fourms.php?m=bbs&cateid=403
贾玉华
PW 8.7内测组
PW 8.7内测组
  • 发帖数1947
  • 铜币13439两
  • 威望2307点
  • 贡献1点
  • 注册日期2011-02-15
  • 最后登录2018-01-13
  • 社区居民
  • 忠实会员
  • 最爱沙发
3楼#
发布于:2017-03-04 13:18
系统提示:关于phpwind产品的学习与交流已经迁移到阿里云论坛,请访问这里:https://bbs.aliyun.com/fourms.php?m=bbs&cateid=403
魅柒
论坛版主
论坛版主
  • 发帖数1775
  • 铜币17041两
  • 威望936点
  • 贡献0点
  • 注册日期2012-07-14
  • 最后登录2017-09-25
  • 社区居民
  • 忠实会员
  • 最爱沙发
  • 社区明星
4楼#
发布于:2017-03-04 17:11
系统提示:关于phpwind产品的学习与交流已经迁移到阿里云论坛,请访问这里:https://bbs.aliyun.com/fourms.php?m=bbs&cateid=403
贾玉华:@元芳 帮忙看下@孤独之虎 @bink1224 @魅柒回到原帖
额~这~
贾玉华
PW 8.7内测组
PW 8.7内测组
  • 发帖数1947
  • 铜币13439两
  • 威望2307点
  • 贡献1点
  • 注册日期2011-02-15
  • 最后登录2018-01-13
  • 社区居民
  • 忠实会员
  • 最爱沙发
5楼#
发布于:2017-03-04 20:07
系统提示:关于phpwind产品的学习与交流已经迁移到阿里云论坛,请访问这里:https://bbs.aliyun.com/fourms.php?m=bbs&cateid=403
魅柒:额~这~回到原帖
您只要出马,绝对是小菜一碟!
魅柒
论坛版主
论坛版主
  • 发帖数1775
  • 铜币17041两
  • 威望936点
  • 贡献0点
  • 注册日期2012-07-14
  • 最后登录2017-09-25
  • 社区居民
  • 忠实会员
  • 最爱沙发
  • 社区明星
6楼#
发布于:2017-03-05 08:19
系统提示:关于phpwind产品的学习与交流已经迁移到阿里云论坛,请访问这里:https://bbs.aliyun.com/fourms.php?m=bbs&cateid=403
贾玉华:您只要出马,绝对是小菜一碟!回到原帖
拆分后是指什么?
贾玉华
PW 8.7内测组
PW 8.7内测组
  • 发帖数1947
  • 铜币13439两
  • 威望2307点
  • 贡献1点
  • 注册日期2011-02-15
  • 最后登录2018-01-13
  • 社区居民
  • 忠实会员
  • 最爱沙发
7楼#
发布于:2017-03-05 11:11
系统提示:关于phpwind产品的学习与交流已经迁移到阿里云论坛,请访问这里:https://bbs.aliyun.com/fourms.php?m=bbs&cateid=403
魅柒:拆分后是指什么?回到原帖
指拆分后,帖子在pw_posts里没能正确更新为目标主题所在的版块id,如主楼第2个图所示,导致无法编辑,提示”帖子id非法“。已经基本确认,问题产生的原因是,拆分操作时,没能把帖子的版块id更新为目标主题所在的版块id。只要能通过拆分管理模板输入的目标版块id(编辑模板新增),由masingle.php文件把目标主题id和目标版块id一起更新到pw_posts表就可以解决了。
贾玉华
PW 8.7内测组
PW 8.7内测组
  • 发帖数1947
  • 铜币13439两
  • 威望2307点
  • 贡献1点
  • 注册日期2011-02-15
  • 最后登录2018-01-13
  • 社区居民
  • 忠实会员
  • 最爱沙发
8楼#
发布于:2017-03-05 11:21
系统提示:关于phpwind产品的学习与交流已经迁移到阿里云论坛,请访问这里:https://bbs.aliyun.com/fourms.php?m=bbs&cateid=403
我知道大神一直都在忙pw10,对于pw8.7已经基本不再关注了,但现在看官方还能来的会员里,似乎也只有你能解决这个问题了。我不懂代码,能基本确认问题可能产生的原因,已经是尽最大努力了,可不懂代码,不知道如何才能把新增加的目标版块id更新到pw_posts表里。虽然问题不大,可既然已经知道问题产生的原因,还是希望能够解决。而希望也只能暂时寄托在大神身上了,不知道能否在闲暇时帮忙看下,我相信只要您能出马,用不了多长时间就能解决的,而让我自己去研究代码,似乎只能是不可能完成的任务了。
贾玉华
PW 8.7内测组
PW 8.7内测组
  • 发帖数1947
  • 铜币13439两
  • 威望2307点
  • 贡献1点
  • 注册日期2011-02-15
  • 最后登录2018-01-13
  • 社区居民
  • 忠实会员
  • 最爱沙发
9楼#
发布于:2017-03-05 11:35
系统提示:关于phpwind产品的学习与交流已经迁移到阿里云论坛,请访问这里:https://bbs.aliyun.com/fourms.php?m=bbs&cateid=403
代码很多,所以没法理解大概意思,贴上来方便查看,不用找文件了。
} elseif ($action == 'split') { //拆分帖子 S::gp(array('fid','tid','page','selid','splittype','splitid','splittitle','ifmsg','atc_content')); $tid = (int)$tid; $page = (int)$page; $fid = (int)$fid; empty($selid) && Showmsg('split_no_thread'); if (!$_POST['step']) { $splitNum = count($selid); //选中数量 $reason_sel = ''; $reason_a = explode("\n",$db_adminreason); foreach ($reason_a as $k => $v) { if ($v = trim($v)) { $reason_sel .= "<option value=\"$v\">$v</option>"; } else { $reason_sel .= "<option value=\"\">-------</option>"; } } require_once PrintEot($template); footer(); } else { PostCheck(); $splittype = (int)$splittype; //拆分类型 $pids = array(); //拆分的id $lastPid = NULL; //拆分中最后一个帖子ID $firstPid = NULL; //拆分的第一个帖子ID foreach ($selid as $k => $v) { if(is_numeric($v)) { $pids[] = $v; if($v > $lastPid) $lastPid = $v; if($v < $firstPid) $firstPid = $v; } } $pidsNum = count($pids); //回复数 $pingService = L::loadClass("ping", 'forum'); //tucool $foruminfo = L::forum($fid); $istucool = $foruminfo['forumset']['iftucool'] && $foruminfo['forumset']['tucoolpic']; $istucool && $tucoolService = L::loadClass('Tucool','forum'); if ($selid[0] == 'tpc') { //需要拆分主题帖子 if ($splittype == 0) { //新帖操作 //判断和获取数据 $pw_tmsgs_tid = GetTtable($tid); //获取分表表名 $pw_posts_tid = GetPtable('N',$tid); //post表 if(strlen($splittitle) == 0) Showmsg('split_title_not_null'); if(strlen($splittitle) > 100) Showmsg('split_title_not_big'); $splitTopic = $db->get_one("SELECT * FROM pw_threads WHERE tid = ".S::sqlEscape($tid)); //pw_thread if(!$splitTopic) Showmsg("split_no_thread"); $splitTopicMsg = $db->get_one("SELECT * FROM $pw_tmsgs_tid WHERE tid = ".S::sqlEscape($tid)); //pw_tmsg $splitNum = $splitTopic['replies'] + 1; if($pidsNum == $splitTopic['replies']) Showmsg("split_not_all"); //不允许全部帖子拆分 //拆到新帖子操作 $lastNewThreadPost = $lastPid ? $db->get_one("SELECT * FROM $pw_posts_tid WHERE pid = ".S::sqlEscape($lastPid)) : false; //新帖回复 if($lastNewThreadPost !== false){ $splitTopic['lastpost'] = $lastNewThreadPost['postdate']; $splitTopic['lastposter'] = $lastNewThreadPost['author']; }else{ $splitTopic['lastpost'] = $splitTopic['postdate']; $splitTopic['lastposter'] = $splitTopic['author']; } $splitTopic['ptable'] = $db_ptable; //分表 $splitTopic['subject'] = $splittitle; unset($splitTopic['tid']); $splitTopic['replies'] = $pidsNum; //回复数 $splitTopic['topped'] == 4 && $splitTopic['topped'] = 0; $newId = pwQuery::insert("pw_threads" ,$splitTopic); $pw_tmsgs = GetTtable($newId); //获取分表表名 $pw_posts = GetPtable('N',$newId); //获取分表表名 $splitTopicMsg['tid'] = $newId; if($splitTopicMsg) $db->update("INSERT INTO $pw_tmsgs SET " . S::sqlSingle($splitTopicMsg)); $splitid = $newId; //如果有置顶的情况 $forumdata = $db->get_one("SELECT * FROM pw_forumdata WHERE fid = ".S::sqlEscape($splitTopic['fid'])); //获取板块信息 if($forumdata['topthreads'] == ""){ $forumdata['topthreads'] = $newId; }else{ $forumdata['topthreads'] = $forumdata['topthreads'].','.$newId; } if($splitTopic['topped']){ $postTopArr = array(); $postTopArr['fid'] = $splitTopic['fid']; $postTopArr['tid'] = $newId; $postTopArr['uptime'] = 2; $postTopArr['floor'] = $splitTopic['topped']; $db->update("INSERT INTO pw_poststopped SET " . S::sqlSingle($postTopArr)); updatetop(); //require_once(R_P.'admin/cache.php'); //updatecache_forums($postTopArr['fid']); //$db->update("UPDATE pw_forumdata SET top1 = top1 + 1, topic = topic + 1, topthreads = " . S::sqlEscape($forumdata['topthreads'])." WHERE fid = " . S::sqlEscape($splitTopic['fid'])); } //* $db->update("UPDATE pw_forumdata SET topic = topic + 1 WHERE fid = " . S::sqlEscape($splitTopic['fid'])); $db->update(pwQuery::buildClause("UPDATE :pw_table SET topic=topic+1 WHERE fid=:fid", array('pw_forumdata', $splitTopic['fid']))); //回复处理 $pidsStr = S::sqlImplode($pids); if($pw_posts == $pw_posts_tid){ //如果回复数在同一post表 if($pidsStr) $db->query("UPDATE $pw_posts_tid SET tid = ".S::sqlEscape($splitid)." WHERE pid in ($pidsStr)"); //合并操作 }else{ //临界情况 回复分布在不同的post表中 if($pidsStr){ $db->query("INSERT INTO $pw_posts (tid,author,authorid,postdate,userip,ipfrom,content,ifmark,ifconvert,ifwordsfb,ifsign,ifcheck,remindinfo) (SELECT tid,author,authorid,postdate,userip,ipfrom,content,ifmark,ifconvert,ifwordsfb,ifsign,ifcheck,remindinfo FROM $pw_posts_tid as a WHERE a.pid in ($pidsStr))"); $db->query("UPDATE $pw_posts SET tid = ".S::sqlEscape($splitid)." WHERE tid = ".S::sqlEscape($tid)); } } //被拆帖子操作 $newTopic = $db->get_one("SELECT * FROM $pw_posts_tid WHERE tid = ".S::sqlEscape($tid)." ORDER BY pid ASC LIMIT 1"); //主题帖 $lastPost = $db->get_one("SELECT * FROM $pw_posts_tid WHERE tid = ".S::sqlEscape($tid)." ORDER BY pid DESC LIMIT 1"); $newTopicInfo = array( 'fid' => $fid, 'author' => $newTopic['author'], 'authorid' => $newTopic['authorid'], 'postdate' => $newTopic['postdate'], 'lastpost' => $lastPost['postdate'], 'lastposter'=> $lastPost['author'] ); $pidsNum = $pidsNum + 1; //一个回复变主题 //$db->update("UPDATE pw_threads SET " . S::sqlSingle($newTopicInfo) . " , replies = replies - $pidsNum WHERE tid = ".S::sqlEscape($tid)); pwQuery::update('pw_threads', "tid=:tid",array($tid),null,array(PW_EXPR=>array("replies=replies-{$pidsNum}"))); //回复 Perf::gatherInfo('changeThreads', array('tid'=>$tid)); $pwtmsgInfoMsg = array( 'userip' => $newTopic['userip'], 'content' =>$newTopic['content'], 'ipfrom' => $newTopic['ipfrom'], 'ifsign' => 1, 'ifconvert'=> 2, 'ifwordsfb'=> 1, 'tid' => $tid ); //* $db->update("UPDATE $pw_tmsgs_tid SET " . S::sqlSingle($pwtmsgInfoMsg). " WHERE tid = ".S::sqlEscape($tid)); pwQuery::update($pw_tmsgs_tid, 'tid=:tid', array($tid), $pwtmsgInfoMsg); $db->query("DELETE FROM $pw_posts_tid WHERE pid = ".S::sqlEscape($newTopic['pid'])); //删除成为主题的回复 //评分操作 $db->update("UPDATE pw_pinglog SET tid = ".S::sqlEscape($splitid)." WHERE tid = ".S::sqlEscape($tid)." AND pid = 0"); if($pidsStr) { //$db->update("UPDATE pw_pinglog SET tid = ".S::sqlEscape($splitid)." WHERE tid = ".S::sqlEscape($tid)." AND pid in ($pidsStr)"); pwQuery::update('pw_pinglog', 'tid=:tid AND pid IN(:pid)', array($tid,$pids), array('tid'=>$splitid)); } //$db->update("UPDATE pw_pinglog SET pid = 0 WHERE tid = ".S::sqlEscape($tid)." AND pid = ".S::sqlEscape($newTopic['pid'])." "); pwQuery::update('pw_pinglog', 'tid=:tid AND pid=:pid', array($tid,$newTopic['pid']), array('pid'=>0)); $pingService->update_markinfo($fid, $tid, 0); $pingService->update_markinfo($fid, $splitid, 0); //附件操作 $db->query("UPDATE pw_attachs SET tid = ".S::sqlEscape($splitid)." WHERE tid = ".S::sqlEscape($tid)." AND pid = 0"); if($pidsStr) $db->update("UPDATE pw_attachs SET tid = ".S::sqlEscape($splitid)." WHERE tid = ".S::sqlEscape($tid)." AND pid in ($pidsStr)"); $db->update("UPDATE pw_attachs SET pid = 0 WHERE tid = ".S::sqlEscape($tid)." AND pid = ".S::sqlEscape($newTopic['pid'])." "); } else { //合并帖子操作 //判断和获取数据 (!$splitid) && Showmsg('split_no_splitid'); $splitid = (int)$splitid; if($tid == $splitid) Showmsg('split_no_common_thread'); $result = $db->get_one("SELECT tid,fid,postdate,author FROM pw_threads WHERE tid = ".S::sqlEscape($splitid)); if(!$result) Showmsg('split_is_no_splitthread'); $splitTopic = $db->get_one("SELECT * FROM pw_threads WHERE tid = ".S::sqlEscape($tid)); //pw_thread $splitNum = $splitTopic['replies'] + 1; if($pidsNum == $splitTopic['replies']) Showmsg("split_not_all"); //不允许全部帖子拆分 //拆分 $pw_tmsgs = GetTtable($tid); $pw_posts_tid = GetPtable('N',$tid); //post表 $pw_posts = GetPtable('N',$splitid); //post表 拆分到的表 $splitTopicInfo = $db->get_one("SELECT * FROM pw_threads WHERE tid = ".S::sqlEscape($tid)); $splitTopicMsg = $db->get_one("SELECT * FROM $pw_tmsgs WHERE tid = ".S::sqlEscape($tid)); $postInfo = array( 'tid' => $splitid, 'fid' => $fid, 'author' =>$splitTopicInfo['author'], 'authorid' =>$splitTopicInfo['authorid'], 'postdate' =>$splitTopicInfo['postdate'], 'userip' =>$splitTopicMsg['userip'], 'ipfrom'=>$splitTopicMsg['ipfrom'], 'content'=>$splitTopicMsg['content'], 'ifmark'=>$splitTopicMsg['ifmark'], 'ifconvert'=>$splitTopicMsg['ifconvert'], 'ifwordsfb'=>$splitTopicMsg['ifwordsfb'], 'ifsign'=>$splitTopicMsg['ifsign'], 'ifcheck'=>$splitTopicInfo['ifcheck'], 'remindinfo'=>$splitTopicMsg['remindinfo'] ); $db->update("INSERT INTO $pw_posts SET " . S::sqlSingle($postInfo)); $postNewId = $db->insert_id(); //回复 $pidsStr = S::sqlImplode($pids); if($pw_posts == $pw_posts_tid){ //如果回复数在同一post表 if($pidsStr) $db->query("UPDATE $pw_posts_tid SET tid = ".S::sqlEscape($splitid)." WHERE pid in ($pidsStr)"); //合并操作 }else{ //临界情况 回复分布在不同的post表中 if($pidStr){ $db->query("INSERT INTO $pw_posts (tid,author,authorid,postdate,userip,ipfrom,content,ifmark,ifconvert,ifwordsfb,ifsign,ifcheck,remindinfo) (SELECT tid,author,authorid,postdate,userip,ipfrom,content,ifmark,ifconvert,ifwordsfb,ifsign,ifcheck,remindinfo FROM $pw_posts_tid as a WHERE a.pid in ($pidsStr))"); $db->query("UPDATE $pw_posts SET tid = ".S::sqlEscape($splitid)." WHERE tid = ".S::sqlEscape($tid)); } } //拆分新帖数据更新操作 $lastPost = $db->get_one("SELECT * FROM $pw_posts WHERE tid = ".S::sqlEscape($splitid)." ORDER BY pid DESC LIMIT 1"); //最后回复帖 $pidsNumSplit = $pidsNum + 1; //$db->query("UPDATE pw_threads SET replies = replies + $pidsNumSplit , lastpost = ".S::sqlEscape($lastPost['postdate'])." , lastposter = ".S::sqlEscape($lastPost['author'])." WHERE tid = ".S::sqlEscape($splitid)); //回复 pwQuery::update('pw_threads', "tid=:tid",array($splitid),array('lastpost'=>$lastPost['postdate'],'lastposter'=>$lastPost['author']),array(PW_EXPR=>array("replies=replies+{$pidsNumSplit}"))); //回复 Perf::gatherInfo('changeThreads', array('tid'=>$splitid)); //被拆分的数据更新 $postInfo = $db->get_one("SELECT * FROM $pw_posts_tid WHERE tid = ".S::sqlEscape($tid)." ORDER BY pid ASC LIMIT 1"); if($postInfo) { $threadInfo = array( 'fid' => $fid, 'author' => $postInfo['author'], 'authorid' => $postInfo['authorid'], 'ifcheck' => $postInfo['ifcheck'], 'postdate' => $postInfo['postdate'], 'lastpost' => $postInfo['postdate'], 'lastposter'=> $postInfo['author'] ); $db->update("UPDATE pw_threads SET " . S::sqlSingle($threadInfo)." WHERE tid = ".S::sqlEscape($tid)); Perf::gatherInfo('changeThreads', array('tid'=>$tid)); $pw_tmsgs = GetTtable($tid); //获取分表表名 $pwtmsgInfo = array( 'userip' => $postInfo['userip'], 'content' => $postInfo['content'], 'ipfrom' => $postInfo['ipfrom'], 'ifsign' => $postInfo['ifsign'], 'ifconvert'=> $postInfo['ifconvert'], 'aid' => $postInfo['aid'], 'ifwordsfb'=> $postInfo['ifwordsfb'] ); //* $db->update("UPDATE $pw_tmsgs SET " . S::sqlSingle($pwtmsgInfo). " WHERE tid = ".S::sqlEscape($tid)); pwQuery::update($pw_tmsgs, 'tid=:tid', array($tid), $pwtmsgInfo); } $lastPostT = $db->get_one("SELECT * FROM $pw_posts_tid WHERE tid = ".S::sqlEscape($tid)." ORDER BY pid DESC LIMIT 1"); //最后回复帖 $pidsNumT = $pidsNum + 1; if($lastPostT !== false){ $db->query("UPDATE pw_threads SET replies = replies - $pidsNumT , lastpost = ".S::sqlEscape($lastPostT['postdate'])." , lastposter = ".S::sqlEscape($lastPostT['author'])." WHERE tid = ".S::sqlEscape($tid)); //回复 } else { $db->query("UPDATE pw_threads SET replies = replies - $pidsNumT , lastpost = ".S::sqlEscape($postInfo['postdate'])." , lastposter = ".S::sqlEscape($postInfo['author'])." WHERE tid = ".S::sqlEscape($tid)); //回复 } Perf::gatherInfo('changeThreads', array('tid'=>$tid)); $db->query("DELETE FROM $pw_posts_tid WHERE pid = ".S::sqlEscape($postInfo['pid'])); //评分操作 $db->update("UPDATE pw_pinglog SET tid = ".S::sqlEscape($splitid)." , pid = ".S::sqlEscape($postNewId)." WHERE tid = ".S::sqlEscape($tid)." AND pid = 0"); if($pidsStr) { //$db->update("UPDATE pw_pinglog SET tid = ".S::sqlEscape($splitid)." WHERE tid = ".S::sqlEscape($tid)." AND pid in ($pidsStr)"); pwQuery::update('pw_pinglog', 'tid=:tid AND pid IN(:pid)', array($tid,$pids), array('tid'=>$splitid)); } //$db->update("UPDATE pw_pinglog SET pid = 0 WHERE tid = ".S::sqlEscape($tid)." AND pid = ".S::sqlEscape($postInfo['pid'])." "); pwQuery::update('pw_pinglog', 'tid=:tid AND pid=:pid', array($tid,$postInfo['pid']), array('pid'=>0)); $pingService->update_markinfo($fid, $tid, 0); $pingService->update_markinfo($fid, $splitid, 0); //附件操作 $db->query("UPDATE pw_attachs SET tid = ".S::sqlEscape($splitid)." , pid = ".S::sqlEscape($postNewId)." WHERE tid = ".S::sqlEscape($tid)." AND pid = 0"); if($pidsStr) $db->update("UPDATE pw_attachs SET tid = ".S::sqlEscape($splitid)." WHERE tid = ".S::sqlEscape($tid)." AND pid in ($pidsStr)"); $db->update("UPDATE pw_attachs SET pid = 0 WHERE tid = ".S::sqlEscape($tid)." AND pid = ".S::sqlEscape($postInfo['pid'])." "); $fjInfo = $db->get_one("SELECT COUNT(*) as a FROM pw_attachs WHERE tid = ".S::sqlEscape($splitid)." AND pid = ".S::sqlEscape($postNewId)." limit 1"); if($fjInfo) $db->update("UPDATE $pw_posts SET aid = ".S::sqlEscape($fjInfo['a'])." WHERE pid = ".S::sqlEscape($postNewId)." "); } //如果分表 删除原表中的回复 if($pw_posts !== $pw_posts_tid){ if($pidsStr){ $db->query("DELETE FROM $pw_posts_tid WHERE pid in ($pidsStr)"); } } } else { //不需要拆分主题帖子 $pw_posts_tid = GetPtable('N',$tid); //post表 if ($splittype == 0) { //新帖操作 if(strlen($splittitle) == 0) Showmsg('split_title_not_null'); if(strlen($splittitle) > 100) Showmsg('split_title_not_big'); //拆分 $threadId = $pids[0]; $postInfo = $db->get_one("SELECT * FROM $pw_posts_tid WHERE pid = ".S::sqlEscape($threadId)); $threadInfo = array( 'fid' => $fid, 'author' => $postInfo['author'], 'authorid' => $postInfo['authorid'], 'subject' => $splittitle, 'ifcheck' => $postInfo['ifcheck'], 'postdate' => $postInfo['postdate'], 'lastpost' => $postInfo['postdate'], 'ptable' => $db_ptable,//分表 'lastposter'=> $postInfo['author'] ); //$db->update("INSERT INTO pw_threads SET " . S::sqlSingle($threadInfo)); $newId = pwQuery::insert("pw_threads" ,$threadInfo); $newId = $db->insert_id(); $pw_tmsgs = GetTtable($newId); //获取分表表名 $pwtmsgInfo = array( 'userip' => $postInfo['userip'], 'content' => $postInfo['content'], 'ipfrom' => $postInfo['ipfrom'], 'ifsign' => $postInfo['ifsign'], 'ifconvert'=> $postInfo['ifconvert'], 'ifwordsfb'=> $postInfo['ifwordsfb'], 'tid' => $newId ); $db->update("INSERT INTO $pw_tmsgs SET " . S::sqlSingle($pwtmsgInfo)); $db->query("DELETE FROM $pw_posts_tid WHERE pid = ".S::sqlEscape($threadId)); $splitid = $newId; //更新板块数据表 //* $db->update("UPDATE pw_forumdata SET topic = topic + 1 WHERE fid = " . S::sqlEscape($fid)); $db->update(pwQuery::buildClause("UPDATE :pw_table SET topic=topic+1 WHERE fid=:fid", array('pw_forumdata', $fid))); } else { //合并帖子操作 (!$splitid) && Showmsg('split_no_splitid'); $splitid = (int)$splitid; if($tid == $splitid) Showmsg('split_no_common_thread'); $result = $db->get_one("SELECT tid,fid,postdate,author FROM pw_threads WHERE tid = ".S::sqlEscape($splitid)); if(!$result) Showmsg('split_is_no_splitthread'); } $splitThread = $db->get_one("SELECT tid,fid,postdate,author,subject FROM pw_threads WHERE tid = ".S::sqlEscape($tid)); $splitTopic = $splitThread; $pw_posts = GetPtable('N',$splitid); if ($splitid) { //最后发帖和时间 $lastPostInfo = $db->get_one("SELECT * FROM $pw_posts_tid WHERE pid = ".S::sqlEscape($lastPid)); $oldLastPostInfo = $db->get_one("SELECT * FROM $pw_posts_tid WHERE tid = ".S::sqlEscape($tid)." ORDER BY pid DESC limit 1"); //回复操作 $pidsStr = S::sqlImplode($pids); if($pw_posts == $pw_posts_tid){ //如果回复数在同一post表 if($pidsStr) $db->query("UPDATE $pw_posts_tid SET tid = ".S::sqlEscape($splitid)." WHERE pid in ($pidsStr)"); //合并操作 }else{ //临界情况 回复分布在不同的post表中 if($pidsStr){ $db->query("INSERT INTO $pw_posts (tid,author,authorid,postdate,userip,ipfrom,content,ifmark,ifconvert,ifwordsfb,ifsign,ifcheck,remindinfo) (SELECT tid,author,authorid,postdate,userip,ipfrom,content,ifmark,ifconvert,ifwordsfb,ifsign,ifcheck,remindinfo FROM $pw_posts_tid as a WHERE a.pid in ($pidsStr))"); $db->query("UPDATE $pw_posts SET tid = ".S::sqlEscape($splitid)." WHERE tid = ".S::sqlEscape($tid)); $db->query("DELETE FROM $pw_posts_tid WHERE pid in ($pidsStr)"); } } //被拆帖子 $pidNum = count($pids); //回复数 if ($oldLastPostInfo) { $db->query("UPDATE pw_threads SET replies = replies - $pidNum,lastpost = ".S::sqlEscape($oldLastPostInfo['postdate']).",lastposter = ".S::sqlEscape($oldLastPostInfo['author'])." WHERE tid = ".S::sqlEscape($tid)); } else { $db->query("UPDATE pw_threads SET replies = replies - $pidNum,lastpost = ".S::sqlEscape($splitThread['postdate']).",lastposter = ".S::sqlEscape($splitThread['author'])." WHERE tid = ".S::sqlEscape($tid)); } Perf::gatherInfo('changeThreads', array('tid'=>$tid)); //拆到的帖子 if($splittype == 0 && $pidNum > 1) $pidNum = $pidNum - 1; if($lastPostInfo){ $db->query("UPDATE pw_threads SET replies = replies + $pidNum,lastpost = ".S::sqlEscape($lastPostInfo['postdate']).",lastposter = ".S::sqlEscape($lastPostInfo['author'])." WHERE tid = ".S::sqlEscape($splitid)); //拆到 回复数 最后发帖人 } Perf::gatherInfo('changeThreads', array('tid'=>$splitid)); //评分操作 if($pidsStr) { //$db->update("UPDATE pw_pinglog SET tid = ".S::sqlEscape($splitid)." WHERE tid = ".S::sqlEscape($tid)." AND pid in ($pidsStr)"); pwQuery::update('pw_pinglog', 'tid=:tid AND pid IN(:pid)', array($tid,$pids), array('tid'=>$splitid)); } if ($splittype == 0) { //$db->update("UPDATE pw_pinglog SET tid = ".S::sqlEscape($splitid)." , pid = 0 WHERE tid = ".S::sqlEscape($splitid)." AND pid = ".S::sqlEscape($postInfo['pid'])); pwQuery::update('pw_pinglog', 'tid=:tid AND pid =:pid', array($tid,$postInfo['pid']), array('tid'=>$splitid,'pid'=>0)); } $pingService->update_markinfo($fid, $tid, 0); $pingService->update_markinfo($fid, $splitid, 0); //附件操作 if($pidsStr) $db->update("UPDATE pw_attachs SET tid = ".S::sqlEscape($splitid)." WHERE tid = ".S::sqlEscape($tid)." AND pid in ($pidsStr)"); if ($splittype == 0) { $db->update("UPDATE pw_attachs SET pid = 0 , tid = ".S::sqlEscape($splitid)." WHERE tid = ".S::sqlEscape($splitid)." AND pid = ".S::sqlEscape($postInfo['pid'])." "); $fjInfo = $db->get_one("SELECT COUNT(*) as a FROM pw_attachs WHERE tid = ".S::sqlEscape($splitid)." AND pid = 0 "); //* $fjInfo && $db->update("UPDATE $pw_tmsgs SET aid = ".S::sqlEscape($fjInfo['a'])." WHERE tid = ".S::sqlEscape($splitid)." "); $fjInfo && pwQuery::update($pw_tmsgs, 'tid=:tid', array($splitid), array('aid'=>$fjInfo['a'])); } } } //tucool if ($istucool) { $tucoolService->updateTucoolImageNum($tid); $tucoolService->updateTucoolImageNum($splitid); } //通知 if ($ifmsg) { M::sendNotice( array($splitThread['author']), array( 'title' => getLangInfo('writemsg','split_title'), 'content' => getLangInfo('writemsg','split_content',array( 'msg' => $atc_content, 'spiltInfo' => "<a href="http://ondara.net/"read.php?tid=".$tid."\">".$splitTopic['subject']."</a>"" )), ) ); } $refreshto = "read.php?tid=$tid&ds=1&page=$pahe"; if (defined('AJAX')) { Showmsg("ajaxma_success"); } else { refreshto($refreshto,'operate_success'); } } } elseif ($action == 'delatc') {
魅柒
论坛版主
论坛版主
  • 发帖数1775
  • 铜币17041两
  • 威望936点
  • 贡献0点
  • 注册日期2012-07-14
  • 最后登录2017-09-25
  • 社区居民
  • 忠实会员
  • 最爱沙发
  • 社区明星
10楼#
发布于:2017-03-06 08:53
系统提示:关于phpwind产品的学习与交流已经迁移到阿里云论坛,请访问这里:https://bbs.aliyun.com/fourms.php?m=bbs&cateid=403
贾玉华:代码很多,所以没法理解大概意思,贴上来方便查看,不用找文件了。
} elseif ($action == 'split') { //拆分帖子
    S::gp(array('fid','tid','page','selid','spl...
回到原帖
目测是循环查询的问题~之前的逻辑又问题的~应该建立一张索引表,然后索引到正确的pw_posts表,以达到正确的查询。改这个工程蛮大的~
贾玉华
PW 8.7内测组
PW 8.7内测组
  • 发帖数1947
  • 铜币13439两
  • 威望2307点
  • 贡献1点
  • 注册日期2011-02-15
  • 最后登录2018-01-13
  • 社区居民
  • 忠实会员
  • 最爱沙发
11楼#
发布于:2017-03-06 11:13
系统提示:关于phpwind产品的学习与交流已经迁移到阿里云论坛,请访问这里:https://bbs.aliyun.com/fourms.php?m=bbs&cateid=403
魅柒:目测是循环查询的问题~之前的逻辑又问题的~应该建立一张索引表,然后索引到正确的pw_posts表,以达到正确的查询。改这个工程蛮大的~回到原帖
不管怎样,还是谢谢你!
贾玉华
PW 8.7内测组
PW 8.7内测组
  • 发帖数1947
  • 铜币13439两
  • 威望2307点
  • 贡献1点
  • 注册日期2011-02-15
  • 最后登录2018-01-13
  • 社区居民
  • 忠实会员
  • 最爱沙发
12楼#
发布于:2017-03-06 11:16
系统提示:关于phpwind产品的学习与交流已经迁移到阿里云论坛,请访问这里:https://bbs.aliyun.com/fourms.php?m=bbs&cateid=403
[贾玉华于2017-03-06 15:36编辑了帖子]
魅惑乐趣
荣誉会员
荣誉会员
  • 发帖数3399
  • 铜币331两
  • 威望4460点
  • 贡献1554点
  • 注册日期2005-05-14
  • 最后登录2017-12-18
  • 社区明星
  • 社区居民
  • 优秀版主奖
13楼#
发布于:2017-03-12 15:08
系统提示:关于phpwind产品的学习与交流已经迁移到阿里云论坛,请访问这里:https://bbs.aliyun.com/fourms.php?m=bbs&cateid=403
$postInfo = array( 'tid' => $splitid, 'fid' => $result['fid'],//修改ruinjoy 'author' =>$splitTopicInfo['author'], 'authorid' =>$splitTopicInfo['authorid'], 'postdate' =>$splitTopicInfo['postdate'], 'userip' =>$splitTopicMsg['userip'], 'ipfrom'=>$splitTopicMsg['ipfrom'], 'content'=>$splitTopicMsg['content'], 'ifmark'=>$splitTopicMsg['ifmark'], 'ifconvert'=>$splitTopicMsg['ifconvert'], 'ifwordsfb'=>$splitTopicMsg['ifwordsfb'], 'ifsign'=>$splitTopicMsg['ifsign'], 'ifcheck'=>$splitTopicInfo['ifcheck'], 'remindinfo'=>$splitTopicMsg['remindinfo'] ); $db->update("INSERT INTO $pw_posts SET " . S::sqlSingle($postInfo)); $postNewId = $db->insert_id(); //回复 $pidsStr = S::sqlImplode($pids); if($pw_posts == $pw_posts_tid){ //如果回复数在同一post表 if($pidsStr) $db->query("UPDATE $pw_posts_tid SET fid = ".S::sqlEscape($result['fid']).",tid = ".S::sqlEscape($splitid)." WHERE pid in ($pidsStr)"); //合并操作 //修改ruinjoy }else{ //临界情况 回复分布在不同的post表中 if($pidStr){ $db->query("INSERT INTO $pw_posts (tid,author,authorid,postdate,userip,ipfrom,content,ifmark,ifconvert,ifwordsfb,ifsign,ifcheck,remindinfo) (SELECT tid,author,authorid,postdate,userip,ipfrom,content,ifmark,ifconvert,ifwordsfb,ifsign,ifcheck,remindinfo FROM $pw_posts_tid as a WHERE a.pid in ($pidsStr))"); $db->query("UPDATE $pw_posts SET fid = ".S::sqlEscape($result['fid']).",tid = ".S::sqlEscape($splitid)." WHERE tid = ".S::sqlEscape($tid));//修改ruinjoy } }//回复操作 $pidsStr = S::sqlImplode($pids); if($pw_posts == $pw_posts_tid){ //如果回复数在同一post表 if($pidsStr) $db->query("UPDATE $pw_posts_tid SET fid = ".S::sqlEscape($result['fid']).",tid = ".S::sqlEscape($splitid)." WHERE pid in ($pidsStr)"); //合并操作//修改ruinjoy }else{ //临界情况 回复分布在不同的post表中 if($pidsStr){ $db->query("INSERT INTO $pw_posts (tid,author,authorid,postdate,userip,ipfrom,content,ifmark,ifconvert,ifwordsfb,ifsign,ifcheck,remindinfo) (SELECT tid,author,authorid,postdate,userip,ipfrom,content,ifmark,ifconvert,ifwordsfb,ifsign,ifcheck,remindinfo FROM $pw_posts_tid as a WHERE a.pid in ($pidsStr))"); $db->query("UPDATE $pw_posts SET fid = ".S::sqlEscape($result['fid']).",tid = ".S::sqlEscape($splitid)." WHERE tid = ".S::sqlEscape($tid));//修改ruinjoy $db->query("DELETE FROM $pw_posts_tid WHERE pid in ($pidsStr)"); } }
魅惑乐趣
荣誉会员
荣誉会员
  • 发帖数3399
  • 铜币331两
  • 威望4460点
  • 贡献1554点
  • 注册日期2005-05-14
  • 最后登录2017-12-18
  • 社区明星
  • 社区居民
  • 优秀版主奖
14楼#
发布于:2017-03-12 15:44
系统提示:关于phpwind产品的学习与交流已经迁移到阿里云论坛,请访问这里:https://bbs.aliyun.com/fourms.php?m=bbs&cateid=403
主要是加了fid = ".S::sqlEscape($result['fid']).",
你可以搜索ruinjoy这个关键词,看看修改的地方
上一页
游客

返回顶部