本帖最后由 mccad 于 2010-11-11 14:43 编辑
我把step_6.php中的内容换成以下内容,以便转换收藏夹内容,成功了。原来step_6中的程序是用于转换交易的帖子,根本没有什么用,改掉也无所谓。当然,我自己是把转换交易帖子的部分转到第5步中去完成,这样pid才能得到正确的ID号。
- <?php
- //pre_home_favorite
- //favid uid id idtype spaceuid title description dateline
- //id username url topic addtime
- if($start <= 1 ) {
- truncatetable('home_favorite');
- $db['discuz']->query("UPDATE {$discuz_tablepre}forum_thread set favtimes=0 ");
- }
- $query = $db['source']->query("SELECT id,username,url,topic,addtime FROM {$source_tablepre}bookmark WHERE topic <>'' and id BETWEEN $start AND $end;") or dexit("检索数据表 'bookmark' 错误!", 'mssql');
- while ($dvp = $db['source']->fetch_assoc($query)) {
- $dvp = array_change_key_case(daddslashes($dvp));
- //pre_forum_post
- $favid = $dvp['id'];
- $uid = getuid($dvp['username']);
- $id = getfavtid($dvp['url']);
- $idtype = 'tid';
- $spaceuid = 0;
- $title =$dvp['topic'];
- $description = '';
- $dateline = timetounix($dvp['addtime']);
- if ($id >0 && $uid >0){
- $t_field1 = array('favid', 'uid', 'id', 'idtype', 'spaceuid', 'title', 'description', 'dateline');
- $t_query1 = getinsertsql("{$discuz_tablepre}home_favorite", $t_field1);
- if ($db['discuz']->query($t_query1)) {
- $db['discuz']->query("UPDATE {$discuz_tablepre}forum_thread set favtimes=favtimes + 1 WHERE tid=$id ");
- $convertedrows ++;
- } else {
- reportlog("转换收藏夹出错 favid = $favid , id = $id");
- }
- }
- $converted = 1;
- $totalrows ++;
- }
- function getfavtid($url) {
- $id = 0;
- if (! strripos($url,"rootid=")) {
- if ($txtid= strrchr($url,"&id=")) {
- $id= substr($txtid,4);
- }
- }
- return $id;
- }
复制代码
|