From c7f5ed7e2bda77ca1134c4f59a2d4f25438e4e37 Mon Sep 17 00:00:00 2001 From: William DURAND Date: Wed, 22 Jun 2011 13:48:43 +0200 Subject: [PATCH] Added a method to get the dbname in Command classes --- Command/PhingCommand.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Command/PhingCommand.php b/Command/PhingCommand.php index 854c053..6402a9c 100644 --- a/Command/PhingCommand.php +++ b/Command/PhingCommand.php @@ -292,6 +292,16 @@ EOT; return array($name, $defaultConfig); } + /** + * Extract the database name from a given DSN + * @param string $dsn A DSN + * @return string The database name extracted from the given DSN + */ + protected function parseDbName($dsn) { + preg_match('#dbname=([a-zA-Z0-9\_]+)#', $dsn, $matches); + return $matches[1]; + } + /** * Write Propel output as summary. *