Home > Backend Development > PHP Tutorial > How to import phpmyadmin to generate sql file_PHP tutorial

How to import phpmyadmin to generate sql file_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 17:05:46
Original
777 people have browsed it

Share the method I use. Only valid for sql files exported by php tutorial myadmin

$dbfile="test.sql";
$content=iconv("utf-8","gb2312",file_get_contents($dbfile));
//Get the created data
//Remove comments
$content=preg_replace("/--.*n/iu","",$content);
//Replace prefix
$content=str_replace("ct_",table_pre,$content);

$carr=array();
$iarr=array();
//Extract create
preg_match_all("/create table .*(.*).*;/ius",$content,$carr);
$carr=$carr[0];
foreach($carr as $c)
{
@mysql tutorial_query($c,$link);
}

//Extract insert
preg_match_all("/insert into .*(.*);/ius",$content,$iarr);
$iarr=$iarr[0];
//Insert data
foreach($iarr as $c)
{
@mysql_query($c,$link);
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/630757.htmlTechArticleShare the method I use. Only valid for sql files exported by php tutorial myadmin $dbfile=test.sql; $content=iconv(utf-8,gb2312,file_get_contents($dbfile)); //Get the created data...
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