Skip to content

Commit 5262b6c

Browse files
committed
Update AddCommand.php
1 parent 9986fc3 commit 5262b6c

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

webfiori/framework/cli/commands/AddCommand.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,16 @@ private function addDbConnection(): int {
7575
$this->println('Trying to connect to the database...');
7676

7777
$addConnection = $this->tryConnect($connInfoObj);
78-
78+
$orgHost = $connInfoObj->getHost();
79+
$orgErr = $addConnection !== true ? $addConnection->getMessage() : '';
80+
7981
if ($addConnection !== true) {
8082
if ($connInfoObj->getHost() == '127.0.0.1') {
83+
$this->println("Trying with 'localhost'...");
8184
$connInfoObj->setHost('localhost');
8285
$addConnection = $this->tryConnect($connInfoObj);
8386
} else if ($connInfoObj->getHost() == 'localhost') {
87+
$this->println("Trying with '127.0.0.1'...");
8488
$connInfoObj->setHost('127.0.0.1');
8589
$addConnection = $this->tryConnect($connInfoObj);
8690
}
@@ -92,8 +96,9 @@ private function addDbConnection(): int {
9296
App::getConfig()->addOrUpdateDBConnection($connInfoObj);
9397
$this->success('Connection information was stored in application configuration.');
9498
} else {
99+
$connInfoObj->setHost($orgHost);
95100
$this->error('Unable to connect to the database.');
96-
$this->error($addConnection->getMessage());
101+
$this->error($orgErr);
97102
$this->confirmAdd($connInfoObj);
98103
}
99104

0 commit comments

Comments
 (0)