Ejemplo n.º 1
0
  foreach($row as $k=>$v) ${strtolower($k)} = addslashes($v);
  $inquery = " INSERT INTO `#@__channeltype`(`ID` , `nid` , `typename` , `maintable` , `addtable` , `addcon` ,
                `mancon` , `editcon` , `useraddcon` , `usermancon` , `usereditcon` , `fieldset` , `listadd` ,
                 `issystem` , `isshow` , `issend` , `arcsta` , `sendrank` , `sendmember`) 
              VALUES('$newid' , '$newnid' , '$newtypename' , '$newmaintable' , '$newaddtable' , '$addcon' ,
               '$mancon' , '$editcon' , '$useraddcon' , '$usermancon' , '$usereditcon' , '$fieldset' , '$listadd' ,
               '0' , '$isshow' , '$issend' , '$arcsta' , '$sendrank' , '$sendmember');
  ";
  $mysql_version = $dsql->GetVersion();
  $mysql_versions = explode(".",trim($mysql_version));
  $mysql_version = $mysql_versions[0].".".$mysql_versions[1];
  $narrs1 = array('maintalbe'=>$newmaintable,'addtalbe'=>$newaddtable);
  $narrs2 = array('maintalbe'=>$maintable,'addtalbe'=>$addtable);
  foreach($narrs1 as $f=>$fn)
  {
    if(!$dsql->IsTable($fn))
    {
        $tb = $narrs2[$f];
        $dsql->SetQuery("SHOW CREATE TABLE {$dsql->dbName}.{$tb}");
	      $dsql->Execute();
		 	  $row = $dsql->GetArray();
		 	  /*
		 	  //根据数据库版本备份表结构,由于主表取消了自动递增字段,因此可以省略此选项
		 	  $eng1 = "ENGINE=MyISAM DEFAULT CHARSET=".$cfg_db_language;
		 	  $eng2 = "ENGINE=MyISAM AUTO_INCREMENT=([0-9]{1,}) DEFAULT CHARSET=".$cfg_db_language;
		 	  if($datatype==4.0 && $mysql_version > 4.0){
		 	      $tableStruct = eregi_replace($eng1,"TYPE=MyISAM",$row[1]);
		 	      $tableStruct = eregi_replace($eng2,"TYPE=MyISAM",$row[1]);
		 	  }
		 	  else if($datatype==4.1 && $mysql_version < 4.1){
		 	      $tableStruct = eregi_replace("TYPE=MyISAM",$eng1,$row[1]);
$trueTable1 = str_replace("#@__",$cfg_dbprefix,$maintable);
$trueTable2 = str_replace("#@__",$cfg_dbprefix,$addtable);
//检查ID是否重复
//--------------------------
$row = $dsql->GetOne("Select * from #@__channeltype where ID='$ID' Or nid like '$nid' Or typename like '$typename' ");
if(is_array($row)){
	$dsql->Close();
	ShowMsg("可能‘频道ID’、‘频道名称/标识’在数据库已存在,不能重复使用!","-1");
	exit();
}
$mysql_version = $dsql->GetVersion();
$mysql_versions = explode(".",trim($mysql_version));
$mysql_version = $mysql_versions[0].".".$mysql_versions[1];
//复制并创建索引表
//--------------------
$istb = $dsql->IsTable($trueTable1);
if(!$istb || ($isdel1==1 && strtolower($trueTable1)!="{$cfg_dbprefix}archives") )
{
	$dsql->SetQuery("SHOW CREATE TABLE {$dsql->dbName}.#@__archives");
  $dsql->Execute();
  $row2 = $dsql->GetArray();
  $dftable = $row2[1];
	$dsql->ExecuteNoneQuery("DROP TABLE IF EXISTS `{$trueTable1}`;");
	$dftable = str_replace("{$cfg_dbprefix}archives",$trueTable1,$dftable);
	$rs = $dsql->ExecuteNoneQuery($dftable);
	if(!$rs){
		$dsql->Close();
		ShowMsg("创建主索引表副本失败!","-1");
		exit();
	}
}