欢迎光临景诺科技软件开发淘宝店

进店请收藏,谢谢

数据批量写入到织梦系统数据库标记为未审核状态

记录:

<?php
// 本类由系统自动生成,仅供测试用途
class IndexAction extends Action {
    public function index(){
		$id = $this->_get('id');		$endid = $this->_get('endid');				
		$typeid = 9;//写入的栏目
		$db = M();				if(!$id || !$endid){
					$listend = $db->table('dede_archives')->limit(1)->order('id desc')->find();		
					exit('no id and endid id must start big from '.$listend['id']);	//必须大于某id开始	
					} 
		$list = $db->table('tb1')->where('status=0')->find();//查找待发布DB未发布的
		if($list){
			$time=time();
			$r1= $db->query("INSERT INTO `dede_arctiny` VALUES(".$id.", ".$typeid.", '0', 0, 1, ".$time.", ".$time.", 1)");//写入到织梦DB	
				$data2['arcrank']=-1;
				$data2['title']=$list['title'];
				$data2['typeid']=$typeid;
				$data2['id']=$id;				$data2['pubdate']=$time;
				$data2['senddate']=$time;				$data2['sortrank']=$time;
				$data2['mid']=1;
				$data2['dutyadmin']=1;
				$data2['weight']=1;
			$r2=$db->table('dede_archives')->add($data2);
			if($r2>0){//写入成功后写入附加表
				$r3= $db->query('INSERT INTO `dede_addonarticle` VALUES('.$id.', '.$typeid.', "'.$list['content'].'", "", "", "127.0.0.1")');
				$r4 = $db->table('tb1')->where("id = ".$list['id'])->setField('status',1);//写入成功后标记为已发布
				if($r4){
					$nextid = $id+1;
					//$this->redirect("index",array('id'=>$nextid));					//if($id=99999 || $id=88888) exit;
					echo 'ok '.$id;
					echo 'next '.$nextid;					if($endid==$id) exit('<br>the end id!');
					echo"<script>window.location.href='/Sphp/index.php?s=/Index/index/id/".$nextid."/endid/".$endid."'</script>";
				}
			}
			//dump($r2);
			//dump($r3);
			exit;
			
		}else{		echo 'no article yet';		}
		
	
	
    }
}

更多

本文固定链接: http://shanmao.me/web-system/dedecms/shu-ju-pi-liang-xie-ru-dao-zhi-meng-xi-tong-shu-ju-ku-biao-ji-wei-wei-shen-zhuang-tai | 山猫的博客

该日志由 admin 于2014年05月16日发表在 织梦cms 分类下,
原创文章转载请注明: 数据批量写入到织梦系统数据库标记为未审核状态 | 山猫的博客