PHP tutorials Export data structures and generate. sql files
$database = ";//Database tutorial name
$options =array (
' Hostname ' = ', '//IP address
' CharSet ' = ' utf8 ',//coded
' filename ' = ' $database. ' SQL ',//file name
' Username ' = ',
' Password ' and ' = '
);
MySQL tutorial _connect ($options [' hostname '], $options [' username '], $options [' Password ']) or Die ("Cannot connect to database!");
mysql_select_db ($database) or Die ("database name is wrong!");
mysql_query ("SET NAMES ' {$options [' CharSet ']} '");
$data = Get_insert_sql ($table);
function dump_table ($table, $fp = null)
{
$need _close = false;
if (Is_null ($fp)) {
$fp = fopen ($table. '. sql ', ' W ');
$need _close = true;
}
$a =mysql_query ("show create TABLE ' {$table} '");
$row =MYSQL_FETCH_ASSOC ($a); Fwrite ($fp, $row [' Create Table ']. '; '); /export Table structure
$rs = mysql_query ("select * from ' {$table} ');
while ($row = Mysql_fetch_row ($rs)) {
Fwrite ($fp, Get_insert_sql ($table, $row));
}
Mysql_free_result ($RS);
if ($need _close) {
Fclose ($FP);
}
}
http://www.bkjia.com/PHPjc/630881.html www.bkjia.com true http://www.bkjia.com/PHPjc/630881.html techarticle PHP Tutorials Export data structures to generate. sql file $database = ';//Database tutorial name $options =array (' hostname ' = ',//ip address ' charset ' = ' utf8 ',//encoded ' filename ') ' = $database. ' S ...