I have a raw sql query I need to run, but the database name changes in each environment (live: db, dev db_test)
I need to get the current database name from the databases.yml file.
How can I get just the current database name?
I am using the Propel ORM
Initially I thought this would be pretty easy via sfPropelDatabase::getConfiguration()
but that returns an array. As such, I had to parse the result to get the data, and I think there's probably a better way than this:
$propel_config = sfPropelDatabase::getConfiguration();
preg_match('/dbname=([^;]+);/', $propel_config['propel']['datasources']['propel']['connection']['dsn'], $matches);
echo $matches[1];
Anyone got anything better?