From f6281c6767dcc658fd0684236f00b8377f90333a Mon Sep 17 00:00:00 2001 From: rhertogh Date: Wed, 23 May 2018 21:15:01 +0200 Subject: [PATCH] Close DB after each model generation Each new app instance will open a new database connection, when generating a lot of models this causes a "Too many connections" error. --- src/commands/BatchController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/commands/BatchController.php b/src/commands/BatchController.php index ba04127a..4e6b1ba9 100644 --- a/src/commands/BatchController.php +++ b/src/commands/BatchController.php @@ -403,6 +403,7 @@ public function actionModels() $app = \Yii::$app; $temp = new \yii\console\Application($this->appConfig); $temp->runAction(ltrim($route, '/'), $params); + $temp->get($this->modelDb)->close(); unset($temp); \Yii::$app = $app; \Yii::$app->log->logger->flush(true);