<?PHP function table2sql($table) { global $db; $tabledump = "DRO
<?PHP
function table2sql($table)
{
global $db;
$tabledump = "DROP TABLE IF EXISTS $table;\n";
$createtable = $db->query("SHOW CREATE TABLE $table");
$create = $db->fetch_row($createtable);
$tabledump .= $create[1].";\n\n";
return $tabledump;
}
function data2sql($table)
{
global $db;
$tabledump = "DROP TABLE IF EXISTS $table;\n";
$createtable = $db->query("SHOW CREATE TABLE $table");
$create = $db->fetch_row($createtable);
$tabledump .= $create[1].";\n\n";
$rows = $db->query("SELECT * FROM $table");
$numfields = $db->num_fields($rows);
$numrows = $db->num_rows($rows);
while ($row = $db->fetch_row($rows))
{
$comma = "";
$tabledump .= "INSERT INTO $table VALUES(";
for($i = 0; $i < $numfields; $i++)
{
$tabledump .= $comma."'".Mysql_escape_string($row[$i])."'";
$comma = ",";
}
$tabledump .= ");\n";
}
$tabledump .= "\n";
return $tabledump;
}
?>
--结束END--
本文标题: php 备份数据库类
本文链接: https://www.lsjlt.com/news/9431.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0