<?php
/*
投票成员表：pre_forum_pollvoter
*/
if($start <= 1){
	truncatetable('forum_pollvoter');
}

$maxcount = $xc->db['source']->result($xc->db['source']->query("SELECT max(tid) FROM {$source_tablepre}voter"), 0);

if($start < $maxcount){
	$converted = 1;
}

$query = $xc->db['source']->query("SELECT * FROM {$source_tablepre}voter WHERE tid >=$start AND tid < $start + $rpp ") or dexit();
while ($pwvoter =	$xc->db['source']->fetch_array($query)) {
	//pre_forum_pollvoter
	$tid		=	$pwvoter['tid'];
	$uid		=	$pwvoter['uid'];
	$username	=	daddslashes($pwvoter['username']);
	
	//查库获取投票选项的ID
	$vote		=	$pwvoter['vote'];
	$nvote		=	$vote+1;
	$options	=	$xc->db['discuz']->result($xc->db['discuz']->query("SELECT polloptionid FROM {$discuz_tablepre}forum_polloption WHERE tid='$tid' limit $vote,$nvote"), 0);
	
	$dateline	=	$pwvoter['dateline'];

	$field1	=	array('tid','uid','username','options','dateline');
	$query1	=	getinsertsql("{$discuz_tablepre}forum_pollvoter", $field1);

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