对帝国cms指定栏目数据按条件进行批量移动,代码参考帝国cms函数MoveNews_all改写成如下:
require("../../class/connect.php");
require("../../class/functions.php");
require("../../class/db_sql.php");
include('../../data/dbcache/class.php');
$link=db_connect();
$empire=new mysqlquery();
//需要移动栏目ID
$classid=1;
$tbname=$class_r[$classid]['tbname'];
//这里指定对审核的主表信息进行移动
$infotb=ReturnInfoMainTbname($tbname,1);
//移动的条件
/**
1==国外PPT
2==Keynote
3==原创模版
4==会员免费
5==PPT图表
17 国外PPT
18 Keynote
19 PPT元素
20 会员专区
**/
//原来是根据navid分类的,后面由于发展的需要改成栏目进行分类方便管理。
$to_class=array(1=>17,2=>18,4=>20,5=>19);
//var_dump($class_r);
//echo "select * from {$infotb} where classid={$classid} and navid !=3 order by newstime limit 2";
//die();
$sql=$empire->query("select * from {$infotb} where classid='{$classid}' and navid !='3' limit 300");
while($r=$empire->fetch($sql)) //循环获取查询记录
{
if(!$r){
continue;
}
//信息地址
$infourl=GotoGetTitleUrl($to_class[$r['navid']],$r['id'],$r['newspath'],$r['filename'],$r['groupid'],$r['isurl'],$r['titleurl']);
//返回表信息
$infotbr=ReturnInfoTbname($tbname,1,$r['stb']);
//主表
$empire->query("update ".$infotb." set classid='{$to_class[$r['navid']]}',titleurl='$infourl' where id='".$r['id']."'");
//副表
$empire->query("update ".$infotbr['datatbname']." set classid='{$to_class[$r['navid']]}' where id='".$r['id']."'");
//更新栏目信息数
AddClassInfos($r['classid'],'-1','-1',1);
AddClassInfos($to_class[$r['navid']],'+1','+1',1);
//更新信息附加表
UpdateSingleInfoOtherData($r['classid'],$r['id'],$to_class[$r['navid']],$r,0,0);
$empire->query("update {$dbtbpre}ecms_".$tbname."_index set classid='{$to_class[$r['navid']]}' where id='".$r['id']."'");
echo '信息ID为'.$r['id'].'移动成功<br/>';
}
db_close();
$empire=null;如果本文对你有帮助,欢迎打赏本站

支付宝扫码打赏
微信扫码打赏
