i've found a solution ;-)
here is it for all who are interested in:
in the databases.yml file:
insert one schema with one database-definiton:
all:
propel:
class: sfPropelDatabase
param:
phptype: mysql
hostspec: localhost
database: db
username: user
password: pw
port: 3306
encoding: utf8
persistent: true
add this line in a filter, to call it every time:
$env = $this->getContext()->getConfiguration()->getEnvironment();
$configuration = $this->getContext()->getInstance()-
>getConfiguration()->getApplicationConfiguration('frontend',$env,0);
$myDatabaseManager = new myDatabaseManager($configuration);
$myDatabaseManager->initialize($configuration);
add a myDatabaseManager-class in your global or application lib-dir:
class myDatabaseManager extends sfDatabaseManager{
public function initialize(sfApplicationConfiguration $config) {
$test = sfContext::getInstance()->getUser()-
>getAttribute('mySuperDb') ;
if(!isset($test)) $test = 'db' ;
$database = new sfPropelDatabase();
$database->initialize(array ('dsn' => 'mysql://
user:[EMAIL PROTECTED]/'.$test), 'propel');
$this->databases['propel'] = $database;
}
}
if you have any questions, write me an email...
On 7 Nov., 12:04, triggertoo <[EMAIL PROTECTED]> wrote:
> problem description:
> i have a symfony app with multiple databases.
> every client has his own database, these are configured in the
> schema.yml file.
>
> now if a user logs in, the related database should automatically be
> loaded.
>
> my Question:
> is there a way to set a default database in the login process so i
> don't need to call the parameter
> Propel::getConnection('slave') in $articles =
> ArticlePeer::doSelect($c, Propel::getConnection('slave'));
> every time?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---