rradutzu/zend2-doctrine-dynamic-db
Composer 安装命令:
composer require rradutzu/zend2-doctrine-dynamic-db
包简介
Zend2/3 Doctrine Module that allows defining connections using dynamic database names
README 文档
README
Zend2 Doctrine Module that allows defining connections using dynamic database names
#Usage
- Include 'DoctrineDynamicDb' in your modules.config.php file
- Add to the used connection the 'dbNameFactory' param.:
return array(
//...
'doctrine' => array(
'connection' => array(
//...
'orm_dynamic' => array(
'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
'params' => array(
'host' => 'localhost',
'port' => '3306',
'user' => 'root',
'password' => 'kotor3',
'dbname' => '%',
// this needs to return instance of DoctrineMultiDbAdapter\Client\ClientInterface,
// a custom object or a string which represents the db name
'dbNameFactory' => 'ClientFactory',
// optional | name of the method used to retrieve the db name if dbNameFactory
// returns a custom object
'dbNameFactoryMethod' => 'getClientDb'
)
)
),
'dynamic_entitymanager' => array(
// need to add the connection to the new entity manager
'orm_dynamic' => array()
)
),
//...
);
3.Get the entity manager for the dynamic connection using:
$em = $serviceLocator->get('doctrine.dynamic_entitymanager.##connection_name##');
统计信息
- 总下载量: 16.02k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0
- 更新时间: 2015-12-03