php – Laravel DB插入错误:允许的内存大小已用尽

php – Laravel DB插入错误:允许的内存大小已用尽,第1张

概述我试图在我的数据库中插入~20K记录时遇到了问题.我注意到即使我在foreach循环中回显,我也没有在命令行中输出任何内容.相反,我插入~9440有关…的记录后出错 Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 91 bytes) in /Users/me/Sites/Laravel 我试图在我的数据库中插入~20K记录时遇到了问题.我注意到即使我在foreach循环中回显,我也没有在命令行中输出任何内容.相反,我插入~9440有关…的记录后出错

Fatal error: Allowed memory size of 134217728 bytes exhausted (trIEd
to allocate 91 bytes) in
/Users/me/Sites/Laravel/database/connection.PHP on line 293

这是我的代码(尝试使用Eloquent和Fluent):

<?PHPclass Process_Controller extends Base_Controller{    public function action_migrate()    {        $propertIEs = DB::table('raw_propertIEs')->get('ID');        $total = count($propertIEs);        foreach ($propertIEs as $x => $p) {            $r = RawProperty::find($p->ID);            $count = $x + 1;            $prop_details = array(                'column' => $r->fIEld,// Total of 21 fIElds            );            DB::table('propertIEs')->insert($prop_details);            echo "Created #$count of $total\n";        }    }}
此错误表明由于为脚本分配的内存不足,您的PHP脚本已耗尽内存限制.

您需要使用ini_set函数增加memory_limit例如ini_set(‘memory_limit’,’128M’);

总结

以上是内存溢出为你收集整理的php – Laravel DB插入错误:允许的内存大小用尽全部内容,希望文章能够帮你解决php – Laravel DB插入错误:允许的内存大小已用尽所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1258718.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-07
下一篇 2022-06-07

发表评论

登录后才能评论

评论列表(0条)

保存