-
------ Answer -------- The second question has not been done yet. pay attention to this question. The third problem: the simplest one is to execute the mysqldump command.
- $ Database = ""; // name of the backup database
- $ User = ""; // database connection username
- $ Password = ""; // database password
- $ Outputfile = ""; // export the SQL file path of the backup
- System ($ mysqldump. "-u". $ user. "-p". $ password. "". $ database. ">". $ outputfile ."");
- ?>
------ Answer -------- you can use mysql client software to solve these problems, and use mysql cc or mysql front to meet your requirements, it will be very troublesome to use the program ------ answer -------- The execution is not enough or google php mysql class adobd lite ------ answer -------- good ------ answer -------- for 1 and 3, you can use the command line provided by mysql to complete the import and export work. assume that the mysql User name and password are root xxx, and the database is test to import SQL mysql-hlocalhost-uroot-pxxx test <xxx. SQL export SQL mysqldump-hlocalhost-uroot-pxxx database> xxx. SQL for excel, the standard data can be converted into cvs data, and then use phpmyadmin Tool import ------ answer -------- two methods: 1. directly execute the mysql command to let Mysql read the corresponding file 2. read the file with PHP, and then execute the file content. ------ Answer -------- 1, 3 is very simple 2. basically, there is no perfect solution in the Chinese environment. you can use DOM to write a small program for conversion ------ the answer -------- is COM. = | ------ answer -------- The second question: you can write a csv file to import the data to the mysql database. ------ answer -------- The csv file in excel... = _ = | the data is simple and can be used for a moment ------ answer -------- support 1. For questions on the second floor, consider mysql odbc ------ answer -------- Reference the response from froole on the 7th floor: 1. execute the Mysql command directly to allow Mysql to read the corresponding file. 2. use PHP to read the file and then execute the file content. Concise and clear expression ------ answer -------- the above points are high and sweaty. The hosts file is read and written into the database. Changing to PHP is completely new. what you want to do is to import the organized. xls file directly to mysql through PHP. isn't that all possible. What are the best methods for batch import? For example, you need to import the student ID of all the students in a school. ------ Answer -------- The gingzai777 expert's method is being tested. Is it true that the address after source must be an absolute address? ------ Answer -------- Reference gingzai777 on the first floor: 1. import the existing SQL file to the database. I will write a function:
- $ Conn = mysql_connect ("localhost", "root", "password"); // specify the database connection parameters
- Function mysql_import ($ file, $ database) // The Imported function. the parameter is the SQL file path and the imported database name.
- {
- Mysql_select_db ($ database );
- Mysql_query ("source". $ file ."';");
- Echo "import". $ file. "file to". $ database. "database completed ";
- }
- Mysql_close ($ conn );
- ?>
-
+ --------- Code--------------- +
- Function init_db (){
- $ File = "../install/import. SQL ";
- $ Conn = mysql_connect ($ this-> dbhost, $ this-> dbuser, $ this-> dbpw) or die ("database connection error ");
- If (! $ Conn ){
- Echo "database connection error ";
- }
- $ Db = mysql_select_db ($ this-> dbname );
- If ($ db ){
- Mysql_query ("drop database" '. $ this-> dbname .""');
- }
- Mysql_query ("setnames 'gbk '");
- $ Creatdb = mysql_query ("create database" '. $ this-> dbname. "'Default character set gb2312 COLLATE gb2312_bin"); // CREATE a DATABASE
- $ Mysql = mysql_select_db ($ this-> dbname );
- // If ($ mysql ){
- // Echo "connect ";
- //} Else {
- // Echo "not connected ";
- //}
- // Echo $ file;
- // $ File = "source". $ file ."'";
- // Echo $ file;
- Mysql_query ("source". $ file. "'"); // initialize the database
- Mysql_close ($ conn );
- }
-
------ Answer -------- 1. import the existing SQL file into the database. I will write a function:
- $ Conn = mysql_connect ("localhost", "root", "password"); // specify the database connection parameters
- Function mysql_import ($ file, $ database) // The Imported function. the parameter is the SQL file path and the imported database name.
- {
- Mysql_select_db ($ database );
- Mysql_query ("source". $ file ."';");
- Echo "import". $ file. "file to". $ database. "database completed ";
- }
- Mysql_close ($ conn );
|