0
我在zf3中使用了doctrine2,而連接多個數據庫導致錯誤。 然後下面是我在global.phpdoctrine2多個數據庫連接在ZF3?
return [
'doctrine' => [
'connection' => [
'orm_default' => [
'driverClass' => PDOMySqlDriver::class,
'params' => [
'host' => '127.0.0.1',
'user' => 'root',
'password' => '123456',
'dbname' => 'zf3.com',
'charset' => 'utf8',
]
],
'orm_passport' => [
'driverClass' => PDOMySqlDriver::class,
'params' => [
'host' => '127.0.0.1',
'user' => 'root',
'password' => '123456',
'dbname' => 'zf3.com.passport',
'charset' => 'utf8',
]
],
],
'entitymanager' => [
'orm_passport' => [
'connection' => 'orm_passport',
]
],
],
];
和驅動程序的配置在module.config.php配置如下:
'doctrine' => [
'driver' => [
__NAMESPACE__ . '_driver' => [
'class' => AnnotationDriver::class,
'cache' => 'array',
'paths' => [__DIR__ . '/../src/Entity']
],
'orm_passport' => [
'drivers' => [
__NAMESPACE__ . '\Entity' => __NAMESPACE__ . '_driver'
]
]
]
],
在我IndexController.php
public function indexAction()
{
// Get recent users
$users = $this->entityManager->getRepository(Users::class)
->findBy(['status'=>Users::ACTIVE_STATUS_NO],['timeCreated'=>'DESC']);
//\Doctrine\Common\Util\Debug::dump($users);
return new ViewModel([
'users' => $users
]);
}
錯誤消息: 未在鏈配置的命名空間中找到類「Passport \ Entity \ Users」Application \ Entity
其中namespace是'module.config.php'文件的內容嗎? '應用程序','護照'? – gsc
我改變我的global.php,添加一些選擇,它的工作原理 –