后端开发|PHP问题
php
后端开发-PHP问题
自适应app介绍下载源码,鼠标离开ubuntu界面,tomcat提高加載速度,星际 锥形爬虫,php编写许愿墙代码,seo 考试lzw
php数据库导出sql文件
易语言搜索引擎源码,ubuntu磁盘读写速度,tomcat服务器8.5,亚马逊 分类爬虫,在php函数中,seo网站推广找行者SEOlzw
php将mysql数据库整库导出生成sql文件的详细代码。
低价出售微交易源码,vscode返回上次编辑,ubuntu path,tomcat 服务器集群,sqlite存儲過程,公司网页设计 无锡,mysql数据库压缩 虚拟主机,vps服务器 挂机赚钱,js画两点的曲线插件,跨境电商前端框架选型,什么叫网络爬虫,php项目管理,甘肃seo公司,接口监控springboot,帝国cms 调用标签,佳弗o2o网站系统,微信公众号网页源代码,织梦论坛模板下载,分页后台代码怎么写,js页面加载等待,项目管理系统源码,易语言 控制台程序 参数lzw
文件名:db_backup.php
源代码:
<?phpini_set("max_execution_time", "180");//避免数据量过大,导出不全的情况出现。$host="";//数据库地址$dbname="";//这里配置数据库名$username="";//用户名$passw="";//这里配置密码$filename=date("Y-m-d_H-i-s")."-".$dbname.".sql";header("Content-disposition:filename=".$filename);//所保存的文件名header("Content-type:application/octetstream");header("Pragma:no-cache");header("Expires:0");//备份数据$i = 0;$crlf="\r\n";global $dbconn;$dbconn = mysql_connect($host,$username,$passw]);//数据库主机,用户名,密码$db = mysql_select_db($dbname,$dbconn);mysql_query("SET NAMES utf8\");$tables =mysql_list_tables($dbname,$dbconn);$num_tables = @mysql_numrows($tables);print "-- filename=".$filename;while($i < $num_tables){$table=mysql_tablename($tables,$i);print $crlf;echo get_table_structure($dbname, $table, $crlf).";$crlf$crlf";//echo get_table_def($dbname, $table, $crlf).";$crlf$crlf";echo get_table_content($dbname, $table, $crlf);$i++;} // /*新增的获得详细表结构*/function get_table_structure($db,$table,$crlf){global $drop;$schema_create = "";if(!empty($drop)){ $schema_create .= "DROP TABLE IF EXISTS `$table`;$crlf";}$result =mysql_db_query($db, "SHOW CREATE TABLE $table");$row=mysql_fetch_array($result);$schema_create .= $crlf."-- ".$row[0].$crlf;$schema_create .= $row[1].$crlf;Return $schema_create;}/*//原来别人的取得数据库结构,但不完整function get_table_def($db,$table,$crlf){global $drop;$schema_create = "";if(!empty($drop))$schema_create .= "DROP TABLE IF EXISTS `$table`;$crlf";$schema_create .= "CREATE TABLE `$table` ($crlf";$result = mysql_db_query($db, "SHOW full FIELDS FROM $table");while($row = mysql_fetch_array($result)){ // $schema_create .= " `$row[Field]` $row[Type]";if(isset($row["Default"]) && (!empty($row["Default"]) || $row["Default"] == "0"))$schema_create .= " DEFAULT $row[Default]\";if($row["Null"] != "YES")$schema_create .= " NOT NULL";if($row["Extra"] != "")$schema_create .= " $row[Extra]";if($row["Comment"] != "")$schema_create .= " Comment $row[Comment]\";$schema_create .= ",$crlf";}$schema_create = ereg_replace(",".$crlf."$", "", $schema_create);$result = mysql_db_query($db, "SHOW KEYS FROM $table");while($row = mysql_fetch_array($result)){$kname=$row[Key_name];if(($kname != "PRIMARY") && ($row[Non_unique] == 0))$kname="UNIQUE|$kname";if(!isset($index[$kname]))$index[$kname] = array();$index[$kname][] = $row[Column_name];}while(list($x,$columns) = @each($index)){$schema_create .= ",$crlf";if($x == "PRIMARY")$schema_create .= " PRIMARY KEY (".implode($columns,", ") . ")";elseif (substr($x,0,6) == "UNIQUE")$schema_create .= " UNIQUE ".substr($x,7)." (" . implode($columns, ", ") . ")";else$schema_create .= " KEY $x (" . implode($columns, ", ") . ")";}$schema_create .= "$crlf)";return (stripslashes($schema_create));}*///获得表内容function get_table_content($db, $table, $crlf){$schema_create = "";$temp = "";$result = mysql_db_query($db, "SELECT * FROM $table");$i = 0;while($row = mysql_fetch_row($result)){$schema_insert = "INSERT INTO `$table` VALUES (";for($j=0; $j
推荐教学:PHP教学