In php, it is relatively simple to import the SQL file generated by phpmyadmin.
Source: Internet
Author: User
Php is a simple way to import SQL files generated by phpmyadmin. we know that many forums or personal blog programs downloaded online have installed pages, to create such an installation program, you must use an SQL file to create a database.
Only valid for SQL files exported by phpmyadmin
The code is as follows:
$ Dbfile = "test. SQL ";
$ Content = iconv ("UTF-8", "GB2312", file_get_contents ($ dbfile ));
// Obtain the created data
// Remove comments
$ Content = preg_replace ("/--. * \ n/iU", "", $ content );
// Replace the prefix
$ Content = str_replace ("ct _", TABLE_PRE, $ content );
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.