0
私はこの記事と非常に似た何かをしようとしています - Dynamic database connection symfony2 - でもSilexです。Doctrine 2とのSilexでの動的データベース接続
ベースデータベースと、動的に接続したいデータベースを正常にセットアップしました。
database:
base:
driver: pdo_sqlite
path: database/dev.sqlite
website:
driver: pdo_sqlite
path: ~
上記$dbs_options
に読み込まれた後、次はこれを設定するために使用されています。私は成功したウェブサイトのデータベースの名前を取得するにはbasedb
を尋問することができる午前私のbefore
イベントで
$app -> register(new DoctrineServiceProvider, ['dbs.options' => $dbs_options]);
// configure the ORM identities
$app -> register(new DoctrineOrmServiceProvider, [
'orm.proxies_dir' => Utils::joinPaths($app -> config -> appRoot, 'running', 'proxies'),
'orm.em.options' => [
'mappings' => $mappings
]
]
);
// set up multiple entity managers and assign the base connection as default
$app['orm.ems.default'] = 'basedb';
$app['orm.ems.options'] = [
'basedb' => [
'connection' => 'base',
'mappings' => $app['orm.em.options']['mappings']
],
'websitedb' => [
'connection' => 'website',
'mappings' => $app['orm.em.options']['mappings']
]
];
を私が接続したいのです。
これは私が立ち往生している場所で、私は知らないし、Silexのデータベース接続を再構成する方法を見つけることができません。誰もこれをやったことがありますか?