modelGenerator: catch the connect Exception to database correctely
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3726 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -35,10 +35,14 @@ class modelGenerator
|
||||
{
|
||||
$getopts = new \getopts ();
|
||||
$getopts->add ("Help", "?h", "help", "Help of the software");
|
||||
$getopts->add ("DSN", "", "dsn:", "DSN - Data Source Name", "dsn");
|
||||
$getopts->add ("Output", "o:", "output:", "Output directory", "dir");
|
||||
$getopts->add ("DSN", "", "dsn:", "DSN - Data Source Name\n".
|
||||
" Exemple : --dsn \"mysql:dbname=DBNAME\"",
|
||||
"dsn");
|
||||
$getopts->add ("Output", "o:", "output:",
|
||||
"Output directory, ./models by default", "dir");
|
||||
$getopts->add ("Namespace", "n:", "namespace:",
|
||||
"The namespace (if '', not added)", "namespaceName");
|
||||
"The namespace (if '', not added), models by default",
|
||||
"namespaceName");
|
||||
$getopts->add ("Username", "u:", "username:", "Username to connect",
|
||||
"username");
|
||||
$getopts->add ("Password", "p:", "password:", "Password to connect",
|
||||
@@ -64,9 +68,17 @@ class modelGenerator
|
||||
$this->dsn = $dsn;
|
||||
$this->modelsDir = $modelsDir;
|
||||
$this->namespaceName = $getopts->get ("Namespace");
|
||||
$this->db = new \dblayeroo ($dsn,
|
||||
$getopts->get ("Username"),
|
||||
$getopts->get ("Password"));
|
||||
try
|
||||
{
|
||||
$this->db = new \dblayeroo ($dsn,
|
||||
$getopts->get ("Username"),
|
||||
$getopts->get ("Password"));
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
file_put_contents ("php://stderr", $e->getMessage ()."\n");
|
||||
exit (3);
|
||||
}
|
||||
}
|
||||
|
||||
/** List all the existing tables in the database
|
||||
|
||||
Reference in New Issue
Block a user