laravel 填充数据前用truncate清空有外键的表时报错

清除表时先忽略外键约束laravel

DB::statement('SET FOREIGN_KEY_CHECKS=0;');
App\User::truncate();
DB::statement('SET FOREIGN_KEY_CHECKS=1;');

参见: http://stackoverflow.com/ques...code

相关文章
相关标签/搜索