最后一个 .csv 文件被处理并加载到 myTable 中,但在此之前还有 30 个其他 .csv 文件 - .csv 文件都被读取,因为我将它们回显到 CLI 并将它们打印到屏幕上,但我无法解决为什么只有最后一个 .csv 被插入到 myTable 中?有任何想法吗?
$mysqli = new mysqli("localhost", "root", "", "mydb");
$dir = "H:/path/20130116/";
$files = "*.csv";
foreach(glob($dir.$files) as $file) {
exec("mysql -u root -e \"USE mydb; myTable; LOAD DATA INFILE '" . $file . "' INTO TABLE myTable FIELDS TERMINATED BY ',' LINES TERMINATED BY '\\n'\"; ");
}