作者 刘锟

update

@@ -37,19 +37,25 @@ class Temp extends Command @@ -37,19 +37,25 @@ class Temp extends Command
37 */ 37 */
38 public function handle() 38 public function handle()
39 { 39 {
40 - $projects = Project::select(['id'])->orderBy('id', 'asc')->get(); 40 + $projects = Project::where('id', '>', 52)->select(['id'])->orderBy('id', 'asc')->get();
41 foreach ($projects as $project) { 41 foreach ($projects as $project) {
42 ProjectServer::useProject($project->id); 42 ProjectServer::useProject($project->id);
43 43
44 //处理关键词首字母 44 //处理关键词首字母
45 - Keyword::select(['id', 'title', 'first_word'])->chunk(1000, function ($query) {  
46 - foreach ($query as $item) {  
47 - if ($item->first_word === null) {  
48 - $item->first_word = $this->getTitleFirstLetter($item->title);  
49 - $item->save(); 45 + try {
  46 + Keyword::select(['id', 'title', 'first_word'])->chunk(1000, function ($query) {
  47 + foreach ($query as $item) {
  48 + if ($item->first_word === null) {
  49 + $item->first_word = $this->getTitleFirstLetter($item->title);
  50 + $item->save();
  51 + }
50 } 52 }
51 - }  
52 - }); 53 + });
  54 + } catch (\Exception $e) {
  55 + $this->output($e->getMessage());
  56 + continue;
  57 + }
  58 +
53 59
54 $this->output('ID:' . $project->id . ',success'); 60 $this->output('ID:' . $project->id . ',success');
55 } 61 }