PHP implements importing CSV large file data into MYSQL database_PHP tutorial

WBOY
Release: 2016-07-13 17:53:45
Original
929 people have browsed it


A colleague has asked me the same question more than once. Here is the simplest implementation in PHP. If you have a better way, please share it:)

The code is as follows:
[php]
$db_host="192.168.1.10";
$db_user="root";
$db_psw="11111";
$db_name="csvimport";

$conn = mysql_connect($db_host,$db_user,$db_psw) or die("Connection occur error");
mysql_select_db($db_name,$conn) or die("Connection occur error");
mysql_query("set names utf-8");


mysql_query("LOAD DATA INFILE '/root/bill20120813121249.csv' INTO TABLE `billdata` FIELDS TERMINATED BY ',' ENCLOSED BY '"' ESCAPED BY '"' LINES TERMINATED BY 'rn' IGNORE 1 LINES;") or die ( 'Error: '.mysql_error ());

?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478007.htmlTechArticleA colleague has asked me the same question more than once. Here is the simplest implementation of PHP. If you have a better way, please share it:) The code is as follows: [php] ?php $db_host=19...
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!