尝试插入大量数据时内部服务器错误500?

时间:2015-12-23 13:58:01

标签: php sql laravel iis laravel-5.1

我有一个问题。我尝试插入大量的数据~400K行。 在执行中间的某个地方 - 我得到错误

  

“内部服务器错误500”。

你可以帮我解决一下吗? (Laravel 5.1,IIS)

public function updateForClients(Request $request) {
    Debugbar::disable();
    if($request->has('sku_list') && $request->has('clients')) {
        DB::disableQueryLog();
        $sku_list = array_map('trim', explode('|', $request->get('sku_list')));
        $clients = array_map('trim', explode('|', $request->get('clients')));
        $text_color_date = Carbon::parse($request->get('text_color_date'));
        $text_color = $request->get('color');
        $sql = [];
        $today = Carbon::now()->format('Y-m-d H:i:s');
        foreach($clients as $client) {
            $sql[$client] = "BEGIN TRANSACTION ";
            $sql[$client] .= "DELETE FROM eltk.dbo.system_products_meta_client WHERE client_id = '" . $client . "' AND sku IN ('". implode("', '", $sku_list) ."') ";
            foreach($sku_list as $sku) {    
                $sql[$client] .= "INSERT INTO eltk.dbo.system_products_meta_client VALUES ('" . $sku . "', '" . $client . "', '" . $text_color . "', '" . $text_color_date . "', '" . $today ."', '" . $today ."') ";
            }
            $sql[$client] .= "COMMIT TRANSACTION GO";
        }
        foreach($sql as $query) {
            DB::statement($query);
        }
        return redirect()->route('product.index')->with('form_success', true)->with('form_message', 'Information saved successfully!');
    }
    return redirect()->back();
}

0 个答案:

没有答案