对于Web应用程序,我必须使用3个单独的数据库:
现在我已经阅读了很多教程和手册来配置这些数据库,所以它现在看起来像这样:
doctrine.global.php
return array(
'doctrine' => array(
'connection' => array(
'orm_default' => array(
'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
'params' => array(
'host' => '123.123.123.123',
'port' => '3306',
'dbname' => 'db_name',
),
),
'orm_oracle' => array(
'driverClass' => 'Doctrine\DBAL\Driver\OCI8\Driver',
'params' => array(
'host' => '321.321.321.321',
'port' => '1521',
'dbname' => 'something',
'driver' => 'oci8',
'servicename' => 'something',
),
),
'orm_microsoft' => array(
'driverClass' => 'Doctrine\DBAL\Driver\SQLSrv\Driver',
'params' => array(
'host' => '231.231.231.231',
'port' => '1433',
'dbname' => 'something',
'driver' => 'sqlsrv',
),
),
)
)
);
doctrine.local.php *
return array(
'doctrine' => array(
'connection' => array(
'orm_default' => array(
'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
'params' => array(
'user' => 'brportal',
'password' => '27607097b4',
),
),
//Alternative DB connection
'orm_oracle' => array(
'driverClass' => 'Doctrine\DBAL\Driver\OCI8\Driver',
'params' => array(
'user' => 'joost',
'password' => '4b58tL8DFv7G',
),
),
'orm_microsoft' => array(
'driverClass' => 'Doctrine\DBAL\Driver\SQLSrv\Driver',
'params' => array(
'user' => 'joost',
'password' => '4b58tL8DFv7G',
),
),
),
'entitymanager' => array(
'orm_default' => array(
'connection' => 'orm_default',
'configuration' => 'orm_default',
),
'orm_oracle' => array(
'connection' => 'orm_oracle',
'configuration' => 'orm_oracle',
),
'orm_microsoft' => array(
'connection' => 'orm_microsoft',
'configuration' => 'orm_microsoft',
),
),
// Use array cache locally, also auto generate proxies on development environment.
'configuration' => array(
'orm_default' => array(
'metadata_cache' => 'array',
'query_cache' => 'array',
'result_cache' => 'array',
'hydration_cache' => 'array',
'generate_proxies' => true,
),
'orm_oracle' => array(
'metadata_cache' => 'array',
'query_cache' => 'array',
'result_cache' => 'array',
'hydration_cache' => 'array',
'generate_proxies' => true,
),
'orm_microsoft' => array(
'metadata_cache' => 'array',
'query_cache' => 'array',
'result_cache' => 'array',
'hydration_cache' => 'array',
'generate_proxies' => true,
),
),
)
);
Module.php
'doctrine' => array(
'driver' => array(
__NAMESPACE__ . '_driver' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache' => 'array',
'paths' => array(__DIR__ . '\..\src\\' . __NAMESPACE__ . '\Entities')
),
'orm_default' => array(
'drivers' => array(
__NAMESPACE__ . '\Entities' => __NAMESPACE__ . '_driver'
)
),
'oracle_driver' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache' => 'array',
'paths' => array(__DIR__ . '\..\src\\' . __NAMESPACE__ . '\Entities\Oracle')
),
'orm_oracle' => array(
'drivers' => array(
__NAMESPACE__ . '\Entities\Oracle' => 'oracle_driver'
)
),
'microsoft_driver' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache' => 'array',
'paths' => array(__DIR__ . '\..\src\\' . __NAMESPACE__ . '\Entities\Microsoft')
),
'orm_microsoft' => array(
'drivers' => array(
__NAMESPACE__ . '\Entities\Microsoft' => 'microsoft_driver'
)
)
)
)
但是现在,我真的希望有一种简单的方法来(重新)生成mssql和oracle数据库实体(注释)。它已经与MySQL数据库一起使用,但我无法找到如何使用doctrine-module orm:convert-mapping
指定数据库连接。
我想知道是否有人可以帮我这个?
先谢谢你们!
ps:我已经读过了: Zend Framework 2 and Doctrine 2 - Configuration for multiple databases
答案 0 :(得分:0)
底线是ZF2 DoctrineORM模块不支持它。有feature request for it on the repo。
与此同时,有一个模块提供了一个添加-em选项的填充模块 https://github.com/SwissEngine/Doctrine-Module-Extension