Created
June 10, 2019 02:32
-
-
Save jocoonopa/8aa1a680ff50194d0f88bd75b36d874e to your computer and use it in GitHub Desktop.
Laravel eloquent 大量資料刪除
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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