jeudi 28 septembre 2017

Checking duplicated data in Laravel

This code work as send to "inn_db" table from "ext_db".

but it was not checked if the data is the same or different in inn_db. So there posited same values in "inn_db". How could I add that job? Thanks.

In Laravel-5.4, MySQL, InnoDB.

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use \DB;

class UpdateCustomerController extends Controller
{
    public function db_update()
    {
        $customers = \DB::connection('ext_db')->table('customers')->orderBy('customer_id')->chunk(1000, function ($all){
            foreach ($all as $kunde){
                DB::connection('inn_db')->table('custoemrs')->insert(
                    [$kunde->customer_id
                     $kunde->name,
                     $kunde->email]);
            }
        });
    }
}



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2xz0t52
via IFTTT

Aucun commentaire:

Enregistrer un commentaire