mercredi 23 décembre 2015

Internal server error 500 when try to insert huge amount of data?

i had a problem. I try to insert huge amount of data ~400K rows. Somewhere in middle of execution - i get error "internal server error 500". Can you help me to solve it? (Laravel 5.1, IIS) Thanks.

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



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire