vendredi 1 avril 2016

Laravel 5.1 deleting duplicates in DB with eloquent

I am wondering how to delete duplicate entries in the DB table, and keeping the new copies in the table. This is how my table looks like:

 $table->increments('id');
 $table->string('text');
 $table->string('type');
 $table->integer('external_id');
 $table->timestamps();

Since I am importing from other DB, and I would like to import all data once a day, means there will be some existing entries already in DB, and new entries as well. Since I need to keep only the entries that are new, I need to delete all old entries (duplicates and unique entries that are not new). Is there a way to do it with Eloquent in Laravel 5.1?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire