也可用于其他数据库的备份,只要改改列名就行,代码如下:
<?php function getFileById() { $conn = mysql_connect ( "localhost" , "root" , "123456" ); mysql_select_db ( "数据库名" ); mysql_query ( "SET NAMES 'UTF8'" ); $result = mysql_query ( "SELECT username,password,email,salt FROM pre_ucenter_members " , $conn ); $d = "" ; while ( $data = mysql_fetch_array ( $result ) ) { $d .= $data [ 'username' ]. "---" . $data [ 'password' ]. "---" . $data [ 'email' ]. "---" . $data [ 'salt' ]. "n" ; } file_put_contents( "d:/wwwroot/back.sql" , $d ); mysql_close( $conn ); } getFileById(); ?>