首页 > 解决方案 > 无法在Mysql数据库laravel中插入超过53条记录

问题描述

我正在尝试将数据从 Excel 文件导入 MySQL 数据库,无论如何,当文件包含例如 100 条记录时,似乎只能导入 53 条记录,我不明白为什么,如果是,我可以从哪里扩展这个数字已经配置好了。

即使文件包含 54 条记录,它也只会导入 53 条。这似乎是固定数字,这是我的代码,它将从 excel 文件接收数据并将其插入数据库

$question_bank_id = $request->input('question_bank');
$tempQuestion = array();
foreach ($request["all_questions"] as $key => $value){

    $request["all_questions"] = array($key => $value);
    Var_dump($request["all_questions"]);
    $$module_name_singular = $module_model::create($request->except('question_bank','earn_list'));
    $$module_name_singular->earn()->attach($request->input('earn_list'));

    array_push($tempQuestion,$$module_name_singular->id);
}

谢谢你

标签: mysqllaravel

解决方案


你没有看到你正在写你正在循环的变量吗?

$question_bank_id = $request->input('question_bank');
$tempQuestion = array();
foreach ($request["all_questions"] as $key => $value){

    // This next line destroys $request["all_questions"]
    // which is the variable you are looping over
    $request["all_questions"] = array($key => $value);

    Var_dump($request["all_questions"]);

    // next 3 line has `$$` and I dont think you ment to
    $$module_name_singular = $module_model::create($request->except('question_bank','earn_list'));

    $$module_name_singular->earn()->attach($request->input('earn_list'));

    array_push($tempQuestion,$$module_name_singular->id);
}

推荐阅读