Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 与条令2和ZF2的辅助数据库连接_Php_Doctrine Orm_Zend Framework2 - Fatal编程技术网

Php 与条令2和ZF2的辅助数据库连接

Php 与条令2和ZF2的辅助数据库连接,php,doctrine-orm,zend-framework2,Php,Doctrine Orm,Zend Framework2,我正在尝试向我的条令配置添加一个额外的连接。我的orm_默认连接工作得非常好,现在我正在尝试添加一个具有自己的条令配置的新模块(主要用于学习目的,但我无法让它工作,这相当烦人) 该模块称为Frontpage,所有相关代码都在其中,除了驻留在local.php中的用户名/密码详细信息 我的错误是 Zend\ServiceManager\Exception\ServiceNotCreatedException An exception was raised while creating "doctr

我正在尝试向我的条令配置添加一个额外的连接。我的orm_默认连接工作得非常好,现在我正在尝试添加一个具有自己的条令配置的新模块(主要用于学习目的,但我无法让它工作,这相当烦人)

该模块称为Frontpage,所有相关代码都在其中,除了驻留在local.php中的用户名/密码详细信息

我的错误是

Zend\ServiceManager\Exception\ServiceNotCreatedException
An exception was raised while creating "doctrine.entitymanager.orm_hosts"; no instance returned
此外,我认为与stacktrace(最后一个异常)相关,但不知道如何修复

Zend\Stdlib\Exception\BadMethodCallException
The option "hydration_cache" does not have a matching setHydrationCache setter method which must be defined
这是我的模块配置(相关部分)文件:

以及我的Module.php的getServiceConfig():

这是在IndexController中失败的getEntityManager()

/**
 * @return array|EntityManager|object
 */
public function getEntityManager() {
    if (NULL === $this->em) {
        /** @var \Doctrine\ORM\EntityManager $em */
        $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_hosts');
        //$em = $this->getServiceLocator()->get('doctrine')->getManager("orm_hosts");
        $this->em = $em;
    }
    return $this->em;
}
如有任何帮助,我们将不胜感激:)

致意
Richard

好的,我仍然不知道上面的代码有什么问题,但是如果我删除

'Hydration_cache' => 'array'
在我的模块配置的条令配置中,它实际上是有效的!不过,如果有人想解释发生了什么,我希望知道更多:)

/**
 * @return array|EntityManager|object
 */
public function getEntityManager() {
    if (NULL === $this->em) {
        /** @var \Doctrine\ORM\EntityManager $em */
        $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_hosts');
        //$em = $this->getServiceLocator()->get('doctrine')->getManager("orm_hosts");
        $this->em = $em;
    }
    return $this->em;
}
'Hydration_cache' => 'array'