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 = new \getopts ();
|
||||||
$getopts->add ("Help", "?h", "help", "Help of the software");
|
$getopts->add ("Help", "?h", "help", "Help of the software");
|
||||||
$getopts->add ("DSN", "", "dsn:", "DSN - Data Source Name", "dsn");
|
$getopts->add ("DSN", "", "dsn:", "DSN - Data Source Name\n".
|
||||||
$getopts->add ("Output", "o:", "output:", "Output directory", "dir");
|
" Exemple : --dsn \"mysql:dbname=DBNAME\"",
|
||||||
|
"dsn");
|
||||||
|
$getopts->add ("Output", "o:", "output:",
|
||||||
|
"Output directory, ./models by default", "dir");
|
||||||
$getopts->add ("Namespace", "n:", "namespace:",
|
$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",
|
$getopts->add ("Username", "u:", "username:", "Username to connect",
|
||||||
"username");
|
"username");
|
||||||
$getopts->add ("Password", "p:", "password:", "Password to connect",
|
$getopts->add ("Password", "p:", "password:", "Password to connect",
|
||||||
@@ -64,10 +68,18 @@ class modelGenerator
|
|||||||
$this->dsn = $dsn;
|
$this->dsn = $dsn;
|
||||||
$this->modelsDir = $modelsDir;
|
$this->modelsDir = $modelsDir;
|
||||||
$this->namespaceName = $getopts->get ("Namespace");
|
$this->namespaceName = $getopts->get ("Namespace");
|
||||||
|
try
|
||||||
|
{
|
||||||
$this->db = new \dblayeroo ($dsn,
|
$this->db = new \dblayeroo ($dsn,
|
||||||
$getopts->get ("Username"),
|
$getopts->get ("Username"),
|
||||||
$getopts->get ("Password"));
|
$getopts->get ("Password"));
|
||||||
}
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
file_put_contents ("php://stderr", $e->getMessage ()."\n");
|
||||||
|
exit (3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** List all the existing tables in the database
|
/** List all the existing tables in the database
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user