简体   繁体   English

如何使用php将ics文件导入mysql?

[英]How to import ics file into mysql using php?

I want to import data from an ics file published using MS-outlook into mysql. 我想将使用MS-outlook发布的ics文件中的数据导入mysql。 How to do this? 这个怎么做?

use this code. 使用此代码。

$filename = "test.tsv";
//Read the file
$content = file_get_contents($filename);
//Split file into lines
$lines  = explode("\n", $content);

//Find columns by reading first line
$columns = explode("\t", $lines[0]);

//Construct create table
$sql_table = "CREATE TABLE IF NOT EXISTS `tsv` (\n";
//Set first column ID
$sql_table .= "  `id` int(11) NOT NULL AUTO_INCREMENT,\n";
foreach ($columns as $column) {
    //Add each column to the string as type text
    $sql_table .= "  `".addslashes($column)."` text NOT NULL,\n";
}
$sql_table .= "  PRIMARY KEY (`id`)\n) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM