Last active
December 15, 2015 23:59
-
-
Save stajnert/5344107 to your computer and use it in GitHub Desktop.
Chane connection with db - symfony 1.4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// connect with other database | |
// $instance - object with new database data | |
new sfDoctrineDatabase(array( | |
'name' => 'instance', | |
'dsn' => 'mysql:host=' . $instance->getInstanceDbHost() . ';dbname=' . $instance->getInstanceDbName(), | |
'username' => $instance->getInstanceDbUser(), | |
'password' => $instance->getInstanceDbPassword(), | |
)); | |
// do something with new db | |
// back to connection from database.yml | |
Doctrine_Manager::getInstance()->getCurrentConnection()->close(); | |
$db = sfContext::getInstance()->getDatabaseManager()->getDatabase('doctrine'); | |
$params = array( | |
$db->getParameter('dsn'), | |
$db->getParameter('username'), | |
$db->getParameter('password'), | |
'doctrine' | |
); | |
Doctrine_Manager::getInstance()->connection($params); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment