Location: PHPKode > projects > Openology PHP Application Integration > openology/backend/sys_bakdat_ok.php
<?php
header('content-type:text/html;charset=UTF-8');
require(dirname(__FILE__)."/config.php");
$conn = connectMySql();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en-EU" lang="en-EU">
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>
<title><?php echo $TEXT['storedata'];?></title>
<link href='css/style.css' rel='stylesheet' type='text/css'>
</head>
<body>
<table id="tt" width="90%" border="0" cellpadding="0" cellspacing="0" align="center">
  <tr>
  <td id="tl">&nbsp;</td>
  <td id="tc"><h2><?php echo $TEXT['storedata'];?>&nbsp;[&nbsp;<a href="javascript:history.go(-1);"><?php echo $TEXT['goBack'];?></a>&nbsp;]</h2></td>
  <td id="tr"></td>
  </tr>
  <tr>
    <td id="l"></td>
    <td id="tf">
<?php
$bakfulldir = $base_dir.$bak_dir;
if(!is_dir($bakfulldir)) @mkdir($bakfulldir,$dir_purview);
if($baktable!="0")
{
	$baktable = trim($baktable);
	$filename = $bakfulldir."/".$baktable.".txt";
	//--获取表的字段总数
	$rs = mysql_list_fields($dbname,$baktable,$conn);
	$i=0;
	$fs="";
	while($row=mysql_fetch_field($rs))
	{
		$fs[$i] = trim($row->name);
		$i++;
	}
	$fsd = count($fs);
	//---------------------------
	$fp = fopen($filename,"w");
	$rs2 = mysql_query("Select * From $baktable",$conn);
	$dd = mysql_num_rows($rs2);
	while($row2 = mysql_fetch_array($rs2))
	{
	    $line = "~Insert Into $baktable(";
	    for($i=0;$i<$fsd;$i++)
		{
			if($i<$fsd-1)
				$line.=trim($fs[$i]).",";
			else
				$line.=trim($fs[$i]).")";
		}
		$line .= " Values(";
		for($i=0;$i<$fsd;$i++)
		{
			if($i<$fsd-1)
				$line.="'".addslashes(trim($row2[$fs[$i]]))."',";
			else
				$line.="'".addslashes(trim($row2[$fs[$i]]))."');\r\n";
		}
		fwrite($fp,$line);
	}
	fclose($fp);
	echo "$backup $baktable ( $dd ) --&gt; $filename OK <br>\r\n";
}
else
{
	$rs = mysql_list_tables($dbname,$conn);
	while($row = mysql_fetch_array($rs))
	{
		$filename = $bakfulldir."/".$row[0].".txt";
		//--获取表的字段总数
		$rsd = mysql_list_fields($dbname,$row[0],$conn);
		$i=0;
		$fs="";
		while($rowd=mysql_fetch_field($rsd))
		{
			$fs[$i] = trim($rowd->name);
			$i++;
		}
		$fsd = count($fs);
		//---------------------------
		$fp = fopen($filename,"w");
		$rs2 = mysql_query("Select * From ".trim($row[0]),$conn);
		$dd = mysql_num_rows($rs2);
		while($row2 = mysql_fetch_array($rs2))
		{
			$line = "~Insert Into ".$row[0]."(";
			for($i=0;$i<$fsd;$i++)
			{
				if($i<$fsd-1)
					$line.=$fs[$i].",";
				else
					$line.=$fs[$i].")";
			}
			$line.=" Values(";
			for($i=0;$i<$fsd;$i++)
			{
				if($i<$fsd-1)
					$line.="'".addslashes(trim($row2[$fs[$i]]))."',";
				else
					$line.="'".addslashes(trim($row2[$fs[$i]]))."');\r\n";
			}
			fwrite($fp,$line);
		}
		fclose($fp);
		echo "$backup ".$row[0]." ( $dd ) --&gt; $filename OK <br>\r\n";
	}
}
?>
    </td>
    <td id="r">&nbsp;</td>
  </tr>
  <tr>
    <td id="bl">&nbsp;</td>
	<td id="bc">&nbsp;</td>
	<td id="br">&nbsp;</td>
</table>
</body>
</html>
Return current item: Openology PHP Application Integration