<?php
/*
收藏帖子
pre_home_favorite
*/

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

$maxuid = $xc->db['source']->result(
	$xc->db['source']->query("SELECT MAX(uid) AS MAXUID FROM {$source_tablepre}favorites"),
	0,
	'MAXUID'
);

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

$query = $xc->db['source']->query("SELECT * FROM {$source_tablepre}favorites WHERE uid>=$start AND uid<=$end");

while($f = $xc->db['source']->fetch_array($query)) {
	$f		=	daddslashes($f);

	$uid		=	$f['uid'];
	$id		=	$f['tid'];
	$idtype		=	'tid';
	$spaceuid	=	0;
	$title		=	$xc->db['discuz']->result(
					$xc->db['discuz']->query("SELECT subject FROM {$discuz_tablepre}forum_thread WHERE tid='$f[tid]'"), 0
				);
	$description	=	'';
	$dateline	=	timetounix($f['favtime']);

	$field1		=	array('uid', 'id', 'idtype', 'spaceuid', 'title', 'description', 'dateline');
	$query1		=	getinsertsql("{$discuz_tablepre}home_favorite", $field1);


	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='.($f['uid']+1).'&stay='.$stay.'&totalrows='.$totalrows.'&convertedrows='.$convertedrows.'&sqlfilenum='.$sqlfilenum;
	file_put_contents(XCONVERT_ROOT.'./cache/lock/progress_'.$step.".txt", $url);
}

?>