我有一个文本文件,其中包含逗号分隔的值,表示数据集,字符串中的每一行。大约有200万个,我想解析字符串,从它们创建Laravel模型,并将每个模型作为一行存储在我的数据库中。
此时,我有一个类,它逐行解析文件并为每个文件创建一个模型,如下所示:
class LargeFileParser{
// File Reference
protected $file;
// Check if file exists and create File Object
public function __construct($filename, $mode="r
我有两个PHP脚本,它们从API加载许多可变资源,导致响应时间长达2.2秒至4秒。对于如何缩短响应时间和提高效率有任何建议将是非常感谢的?
第一脚本
require('path/to/local/API_2');
//Check if user has put a query and that it's not empty
if (isset($_GET['query']) && !empty($_GET['query'])) {
//$query is user input
$query = str_r