Home > Backend Development > PHP Tutorial > PHP exports mysql data table data to generate .sql file_PHP tutorial

PHP exports mysql data table data to generate .sql file_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 17:04:10
Original
1383 people have browsed it

php tutorial export mysql tutorial data table data generation .sql file

$database='';//Database tutorial name
$options=array(
'hostname' => '',//ip address
'charset' => 'utf8',//encoding
'filename' => $database.'.sql',//File name
'username' => '',
'password' => ''
);
mysql_connect($options['hostname'],$options['username'],$options['password'])or die("Cannot connect to database!");
mysql_select_db($database) or die("Wrong database name!");
mysql_query("SET NAMES '{$options['charset']}'");
$data = get_insert_sql($table);


function get_insert_sql($table, $row)
{
$sql = "INSERT INTO `{$table}` VALUES (";
$values ​​= array();
foreach ($row as $value) {
          $values[] = "'" . mysql_real_escape_string($value) . "'";
}
$sql .= implode(', ', $values) . ");";
Return $sql;
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/630882.htmlTechArticlephp tutorial export mysql tutorial data table data generation .sql file $database='';//database tutorial name$ options=array( 'hostname' = '',//ip address 'charset' = 'utf8',//encoding 'filename' = $...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template