prepare($sql); $exeres=$stmt->execute(); $rs=$stmt->fetch(PDO::FETCH_ASSOC); $newsid=$rs['newsid']; $sql="select * from yz_articles where article_category_id=:id order by create_time"; $stmt=$db->prepare($sql); $stmt->bindParam(':id',$id ); $exeres=$stmt->execute(); $rs=$stmt->fetchAll(PDO::FETCH_ASSOC); for($i=0;$ibeginTransaction(); $sql="insert into v9_news (`id`, `catid`, `typeid`, `title`, `posids`, `url`, `listorder`, `status`, `sysadd`, `islink`, `username`, `inputtime`, `updatetime`) values ( :id, :catid, :typeid, :title, :posids, :url, :listorder, :status, :sysadd, :islink, :username, :inputtime, :updatetime)"; $stmt=$db->prepare($sql); $stmt->bindParam(':id',$newsid); $stmt->bindParam(':catid',$catid); $stmt->bindParam(':typeid',$typeid); $stmt->bindParam(':title',$title); $stmt->bindParam(':posids',$posids); $stmt->bindParam(':url',$url); $stmt->bindParam(':listorder',$listorder); $stmt->bindParam(':status',$status); $stmt->bindParam(':sysadd',$sysadd); $stmt->bindParam(':islink',$islink); $stmt->bindParam(':username',$author); $stmt->bindParam(':inputtime',$create_time); $stmt->bindParam(':updatetime',$create_time); $exeres=$stmt->execute(); if($stmt->rowCount()==0) { $errFlag=true; echo "Error1"; }else{ $sql="INSERT INTO v9_news_data (`id`, `content`, `readpoint`, `groupids_view`, `paginationtype`, `maxcharperpage`, `template`, `paytype`, `relation`, `voteid`, `allow_comment`, `copyfrom`) VALUES (:newsid, :content, 0, '', 0, 0, '', 0, '', 0, 1, '|1')"; $stmt=$db->prepare($sql); $stmt->bindParam(':newsid',$newsid); $stmt->bindParam(':content',$content); $exeres=$stmt->execute(); if($stmt->rowCount() > 0 ){ //echo $newsid."OK"; }else{ //echo $newsid."false"; $errFlag=true; echo "Error2"; } } if($errFlag){ $db->rollBack(); }else{ $db->commit(); echo "OK
"; } }