> > > @@ ¿¢¼¿ÆÄÀÏÀ» csvÆÄÀÏ·Î ´Ù¸¥À̸§À¸·Î ÀúÀåÇÑ´Ù. > @@ mysqlDB ¿¡¼ userÅ×À̺íÀ» º¸¸é ÇØ´ç °èÁ¤ÀÇ File_priv ='Y'·Î ¾÷µ¥ÀÌÆ® ÇÑ´Ù. > > 1. mysql¹öÀüÀº 4.0 > mysql> load data infile '/home2/www/whiger/2000coupon.csv' into table coupon fields terminated by '\t' lines terminated by '\n'; > 2. mysql¹öÀü 3.X > mysql> load data local infile '/home2/www/whiger/2000coupon.csv' into table coupon fields terminated by '\t' lines terminated by '\n'; > > > > @@ ¿¢¼¿ÆÄÀÏÀ» ¸ù¶¥º¹»çÇØ¼ txtÆÄÀÏ·Î ¸¸µé¸é Çʵ屸ºÐÀÌ ÅÇŰ·Î ÇØ¼ µÈ´Ù. > <? > > //--------------------- µ¥ÀÌÅͺ£À̽º Á¤º¸ ---------------------// > $host="localhost"; > $username="À¯Àú¸í"; > $userpass="ÆÐ½º¿öµå"; > $dbname="DB¸í"; > > //------------------ µ¥ÀÌÅͺ£À̽º¿¡ ¿¬°á ----------------------// > $connect = mysql_connect($host, $username, $userpass) or die("µ¥ÀÌÅͺ£À̽º ¿¬°á¿¡ ½ÇÆÐÇß½À´Ï´Ù."); > mysql_select_db($dbname, $connect) or die("µ¥ÀÌÅͺ£À̽º ¿¬°á¿¡ ½ÇÆÐÇß½À´Ï´Ù."); > > > $var = file("../coupon.txt"); > $var_count = count($var); > > $query1 = "select count(*) from coupon"; > $result1 = mysql_query($query1,$connect); > $count = mysql_num_rows($result1); > > for($i=0; $i < $var_count; $i++) { > $content = explode("\t",$var[$i]); //ÅÇŰ·Î Çʵ带 ³ª´«´Ù. > $query = "insert into coupon values('$content[0]','$content[1]')"; > mysql_query($query,$connect); > } > > ?> >
* ¿ÞÂÊÀÇ ÀÚµ¿µî·Ï¹æÁö Äڵ带 ÀÔ·ÂÇϼ¼¿ä.