我使用以下代码遍历文件夹中的文件并将数据加载到 MYSQL 表中。我无法完成这项工作。有没有更好的解决方案?
if ($handle = opendir('C:\Documents and Settings\Desktop\CSV Files')) {
while(false !== ($entry = readdir($handle)))
{
mysql_query("LOAD DATA LOCAL INFILE %handle
INTO TABLE main_table
FIELDS
TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
ESCAPED BY '"'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES")
}
}