作者 lyh

gx脚本更新路由

@@ -66,7 +66,6 @@ class UpdateBuildConfiguration extends Command @@ -66,7 +66,6 @@ class UpdateBuildConfiguration extends Command
66 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; 66 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
67 ProjectServer::useProject($v['id']); 67 ProjectServer::useProject($v['id']);
68 $this->getProduct(); 68 $this->getProduct();
69 - gc_collect_cycles(); // 确保内存释放  
70 DB::disconnect('custom_mysql'); 69 DB::disconnect('custom_mysql');
71 } 70 }
72 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; 71 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
@@ -81,10 +80,12 @@ class UpdateBuildConfiguration extends Command @@ -81,10 +80,12 @@ class UpdateBuildConfiguration extends Command
81 */ 80 */
82 public function getProduct(){ 81 public function getProduct(){
83 $productModel = new Product(); 82 $productModel = new Product();
84 - $lists = $productModel->list([],'id',['id','describe']); 83 + $page = 1;
  84 + while (true){
  85 + $lists = $productModel->lists([],$page,$page*5,['id','describe']);
85 $detailModel = new Detail(); 86 $detailModel = new Detail();
86 - if(!empty($lists)){  
87 - foreach ($lists as $k => $v){ 87 + if(!empty($lists['list'])){
  88 + foreach ($lists['list'] as $k => $v){
88 if(empty($v['describe'])){ 89 if(empty($v['describe'])){
89 continue; 90 continue;
90 } 91 }
@@ -104,6 +105,11 @@ class UpdateBuildConfiguration extends Command @@ -104,6 +105,11 @@ class UpdateBuildConfiguration extends Command
104 $detailModel->insert($data); 105 $detailModel->insert($data);
105 } 106 }
106 } 107 }
  108 + }else{
  109 + break;
  110 + return false;
  111 + }
  112 + $page++;
107 } 113 }
108 return true; 114 return true;
109 } 115 }