我有这段代码将文本文件中的数据加载到MySQL
表中。但我不知道为什么它不起作用。
我的PHP代码:
self::$mysqliStmts=DBCon::ConnectToDB();
self::$data=DBCon::QueryDataWithoutProcessing("LOAD DATA INFILE 'C:\wamp\www\php\gagster\Others\friends.txt' INTO TABLE gagster.friends");
mysqli_close(self::$mysqliStmts);
public static function QueryDataWithoutProcessing($query)
{
self::ConnectToDB();
self::$QueryResult=self::$mysqli->query("$query"); //process query
mysqli_close(self::$mysqli); //close connection
return self::$QueryResult; //return result
}
当我编写任何其他查询来代替此查询时,它工作正常。只有此查询会导致问题。
我在 mysql 工作台中运行了查询,它也工作正常。
最佳答案
"Windows path names are specified using forward slashes rather than backslashes. If you do use backslashes, you must double them." - http://dev.mysql.com/doc/refman/5.1/en/load-data.html
关于php - 在mysql文件中加载数据在php脚本中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12141622/