【问题标题】:Can not insert More than 53 Records in Mysql database laravel无法在Mysql数据库laravel中插入超过53条记录
【发布时间】:2020-08-24 12:33:21
【问题描述】:

我正在尝试将数据从 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);
}

谢谢

【问题讨论】:

  • 是的,如果你愿意,你可以插入百万。因此,您最好向我们展示您的代码和数据,并仔细查看错误日志并向我们展示其中的任何错误

标签: mysql laravel


【解决方案1】:

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

$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);
}

【讨论】:

  • 感谢您的回复,但即使我删除了 $request["all_questions"] = array($key => $value);它仍然是 53 条记录
  • 我注意到数组 $request["all_questions"] 没有保存所有数据,它只保存了 53 个元素,我不明白,它与内存有关吗?
  • 那你得看看它是怎么填充的!或者在另一个问题中告诉我们
猜你喜欢
  • 2023-03-21
  • 1970-01-01
  • 1970-01-01
  • 2019-05-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-01-29
相关资源
最近更新 更多