我试图在我的数据库中插入~20K记录时遇到了问题.我注意到即使我在foreach循环中回显,我也没有在命令行中输出任何内容.相反,我插入~9440有关…的记录后出错
原文链接:https://www.f2er.com/laravel/133710.html
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):
<?PHP class 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"; } } }