关于DISCUZ升级程序
DISCUZ版本过低腰升级的话,官方好像也没有升级程序,让DISCUZ提供技术支持,费用太贵,自己处理,以下是核心代码.
注意:cdb_templates 这个表不能导,否则一清空缓存就乱了,切记,花了一天时间才找到.
主程序:
- set_time_limit(9999999);
- include "inc/init.php
- cls::getDatabase()->start();
类程序:
- class common_database{
- //所有有数据的表
- private $_needtable = null;
- //表对应关系 - 优先这样导入
- private $_distablearr = array(
- 'cdb_members'=>array('yzlt_common_member','yzlt_ucenter_members'),
- 'cdb_settings'=>'yzlt_ucenter_settings',
- ''=>''
- );
- //明确禁止导入的表
- private $_disable_table = array('cdb_templates','cdb_buddys','cdb_caches','cdb_favorites','cdb_memberspaces','cdb_mythreads','cdb_myposts','cdb_projects','cdb_stats');
- //构造函数
- public function __construct()
- {
- }
- public function start(){
- //
- $rst = $this->getNeedTable();
- foreach($rst as $tb){
- $this->importTable($tb);//逐个导入表
- //break;
- }
- //收尾工作
- $this->endDoing();
- }
- private function endDoing(){
- //给会员再加密
- $rs = cls::getDB()->getRowsNew("select uid,password from yzlt_ucenter_members");$num = count($rs);
- for($i=0;$i<$num;$i++){
- cls::getDB()->Query("update yzlt_ucenter_members set password='".md5($rs[$i]["password"])."' where uid='".$rs[$i]["uid"]."'");
- }
- //其他操作
- }
- private function getShoulTable($tb){
- $DB1 = cls::getDB(1);
- $sqla = "describe ".$tb."";
- $rsa = $DB1->getRowsNew($sqla);//原来表字段
- $numa = count($rsa);
- $DB = cls::getDB();
- $sql = "show tables";
- $rs = $DB->getRowsNew($sql);$num = count($rs);
- $samenumtj = 0;$mytb='';
- for($i=0;$i<$num;$i++){
- $rscc = $DB->getRowsNew("describe ".$rs[$i][0]);$numcc = count($rscc);
- $samezd = 0;
- for($k1=0;$k1<$numa;$k1++){
- for($k=0;$k<$numcc;$k++){
- if($rsa[$k1][0]==$rscc[$k][0]){
- $samezd++;
- }
- }
- }
- //echo "
- 源表:".$tb.",目标表:".$rs[$i][0].",相同字段数:".$samezd."";
- if((int)$samezd>(int)$samenumtj){
- //echo "----------------".$samenumtj;
- $samenumtj = $samezd;$mytb = $rs[$i][0];
- }
- //$samefield = array_intersect($rsa,$rscc);$samenum = count($samefield);
- //if($samenum>=$samenumtj){
- // $samenumtj = $samenum;$mytb = $rs[$i][0];
- // echo "表名:".$mytb.",相同字段数:".$samenumtj."
- ";
- /

