PHP7中文手册2018 带注释 最新chm版
- header("Content-type:text/html;charset=gbk");
- $host = 'localhost';
- $user = 'root';
- $pass = 'shim';
- $database = 'bitebi';
- $db = mysql_connect($host, $user, $pass);
- mysql_query("use $database", $db);
- mysql_query("set names gbk");
- $table = "abc1";
- $file = "xxx.csv";
- $fp = fopen($file, 'r');
- $frow = fgetcsv($fp);
- foreach($frow as $column) {
- if($columns) $columns .= ', ';
- $columns .= "`$column` varchar(250)";
- }
- $create = "create table if not exists $table ($columns);";
- mysql_query($create, $db);
- $file = dirname(__FILE__).'/'.$file;
- $q = "load data infile '$file' into table $table character set gbk fields terminated by ',' ignore 1 lines";
- mysql_query($q, $db);
- ?>
下载php文件
http://img.kuitao8.com/uploads/2016/0327/20160327010559188.zip
转载请注明:谷谷点程序 » php导入非常大的cvs到mysql