當我想從兩個數據庫中生成實體原則和zend 2我得到這個錯誤:config/autoload/local.php: 我有這個錯誤:致命錯誤:未捕獲的異常'Zend Stdlib Exception BadMethodCallException
Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for doctrine.entitymanager.orm_alternative on line 122:
線122:我有此$entityManager = $this->getServiceLocator() ->get('doctrine.entitymanager.orm_alternative');
return array(
'doctrine' => array(
'connection' => array(
// default connection name
'orm_default' => array(
'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
'params' => array(
'host' => 'localhost',
'port' => '3306',
'user' => 'root',
'password' => '',
'dbname' => 'data1',
'charset' => 'utf8',
'driverOptions' => array(
1002=>'SET NAMES utf8'
),
),
// Alternative DB connection
'orm_alternative' => array(
'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
'params' => array(
'host' => 'localhost',
'port' => '3306',
'user' => 'root',
'password' => '',
'dbname' => 'data2',
'charset' => 'utf8',
'driverOptions' => array(
1002=>'SET NAMES utf8'
),
),
),
// Entity Manager instantiation settings
'entitymanager' => array(
'orm_default' => array(
'connection' => 'orm_default',
'configuration' => 'orm_default',
),
'orm_alternative' => array(
'connection' => 'orm_alternative',
'configuration' => 'orm_alternative',
),
),
Fatal error: Uncaught exception 'Zend\Stdlib\Exception\BadMethodCallException' with message 'The option "orm_al ternative" does not have a callable "setOrmAlternative" ("setormalternative") setter method which must be defin ed' in C:\wamp\www\mp\vendor\zendframework\zend-servicemanager\src\ServiceManager.php on line 943
和
Zend\ServiceManager\Exception\ServiceNotCreatedException: An abstract factory could not create an instance of d octrine.entitymanager.ormdefault(alias: doctrine.entitymanager.orm_default). in C:\wamp\www\mp\vendor\z endframework\zend-servicemanager\src\ServiceManager.php on line 1132
和
Zend\ServiceManager\Exception\ServiceNotCreatedException: An exception was raised while creating "Router"; no i nstance returned in C:\wamp\www\mp\vendor\zendframework\zend-servicemanager\src\ServiceManager.php on l ine 943
我怎樣才能解決這個問題呢?
總是我有這個問題;抽象工廠不能創建doctrine.entitymanager.ormalternative(別名:doctrine.entitymanager.orm_alternative).at行的實例$ entityManager = $ this-> getServiceLocator() \t - > get ( 'doctrine.entitymanager.orm_alternative'); –