<?php
/*
投票选项
pre_forum_polloption
*/

if($start <= 1) {
	truncatetable('forum_polloption');
}



$query = $xc->db['source']->query("SELECT * FROM {$source_tablepre}polloptions WHERE polloptionid>=$start AND polloptionid<=$end") or die("检索数据表 '{$source_tablepre}polloptions' 错误！请将表 '{$source_tablepre}polloptions' 字段类型为 nText 的改为 Text 类型。");

$maxid = $xc->db['source']->result(
	$xc->db['source']->query("SELECT MAX(polloptionid) AS MAXID FROM {$source_tablepre}polloptions"),
	0,
	'MAXID'
);

if($start < $maxid) {
	$converted = 1;
}
while($p = $xc->db['source']->fetch_array($query)) {
	$p		=	daddslashes($p);
	echo $p['voternames'];continue;
	$polloptionid	=	$p['polloptionid'];
	$tid		=	$p['tid'];
	$votes		=	$p['votes'];
	$displayorder	=	$p['displayorder'];
	$polloption	=	$p['polloption'];

	$names		=	explode("\t", $p['voternames']);
	$voterids	=	'';
	for($i=0; $i<count($names); $i++){
		$voterids	.=	getuid($names[$i])."\t";
	}
	$voterids	=	rtrim($voterids, "\t");

	$fields1 = array('polloptionid', 'tid', 'votes', 'displayorder', 'polloption', 'voterids');
	$query1 = getinsertsql("{$discuz_tablepre}forum_polloption", $fields1);

	if ($xc->db['discuz']->query($query1)) {
		$convertedrows ++;
	} else {
		reportlog("无法转换投票选项，SQL 语句如下 ：<br><textarea rows=\"3\" style=\"width: 100%;\">".$query1."</textarea>");
	}
	$converted = 1;
	$totalrows ++;
	$url = 'index.php?mod=dealdata&step='.$step.'&start='.($p['polloptionid']+1).'&stay='.$stay.'&totalrows='.$totalrows.'&convertedrows='.$convertedrows.'&sqlfilenum='.$sqlfilenum;
	file_put_contents(XCONVERT_ROOT.'./cache/lock/progress_'.$step.".txt", $url);
}
?>