Skip to content

Instantly share code, notes, and snippets.

@jocoonopa
Created June 10, 2019 02:32
Show Gist options
  • Save jocoonopa/8aa1a680ff50194d0f88bd75b36d874e to your computer and use it in GitHub Desktop.
Save jocoonopa/8aa1a680ff50194d0f88bd75b36d874e to your computer and use it in GitHub Desktop.
Laravel eloquent 大量資料刪除
<?php
do {
$limitSize = 50000;
$deletedCount = \App\Contact::where('id', '>', 0)->limit($limitSize)->delete();
echo "deleted:{$deleted}\n";
sleep(1); // Be a nice guy
} while (0 < $deletedCount);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment