ask information connection again if they are wrong

This commit is contained in:
Manuel Raynaud
2013-06-05 14:48:42 +02:00
parent c9cd9dabc4
commit 0717c6a48f

View File

@@ -51,11 +51,9 @@ class Install extends ContainerAwareCommand
'' ''
)); ));
do {
$connectionInfo = $this->getConnectionInfo($input, $output); $connectionInfo = $this->getConnectionInfo($input, $output);
} while(false === $connection = $this->tryConnection($connectionInfo, $output));
if (false === $connection = $this->tryConnection($connectionInfo)) {
throw new \RuntimeException("Wrong information, impossible to connect to database");
}
$this->createDatabase($connection, $connectionInfo["dbName"]); $this->createDatabase($connection, $connectionInfo["dbName"]);
@@ -153,7 +151,7 @@ class Install extends ContainerAwareCommand
); );
} }
protected function tryConnection($connectionInfo) protected function tryConnection($connectionInfo, OutputInterface $output)
{ {
$dsn = "mysql:host=%s"; $dsn = "mysql:host=%s";
@@ -165,6 +163,9 @@ class Install extends ContainerAwareCommand
$connectionInfo["password"] $connectionInfo["password"]
); );
} catch (\PDOException $e) { } catch (\PDOException $e) {
$output->writeln(array(
"<error>Wrong connection information</error>"
));
return false; return false;
} }