<small id='6YXoj'></small><noframes id='6YXoj'>

  • <i id='6YXoj'><tr id='6YXoj'><dt id='6YXoj'><q id='6YXoj'><span id='6YXoj'><b id='6YXoj'><form id='6YXoj'><ins id='6YXoj'></ins><ul id='6YXoj'></ul><sub id='6YXoj'></sub></form><legend id='6YXoj'></legend><bdo id='6YXoj'><pre id='6YXoj'><center id='6YXoj'></center></pre></bdo></b><th id='6YXoj'></th></span></q></dt></tr></i><div id='6YXoj'><tfoot id='6YXoj'></tfoot><dl id='6YXoj'><fieldset id='6YXoj'></fieldset></dl></div>
      <bdo id='6YXoj'></bdo><ul id='6YXoj'></ul>

      <tfoot id='6YXoj'></tfoot>
    1. <legend id='6YXoj'><style id='6YXoj'><dir id='6YXoj'><q id='6YXoj'></q></dir></style></legend>

        Zend Framework 2 和 Doctrine 2 - 多个数据库的配置

        Zend Framework 2 and Doctrine 2 - Configuration for multiple databases(Zend Framework 2 和 Doctrine 2 - 多个数据库的配置)
      1. <i id='HeUP7'><tr id='HeUP7'><dt id='HeUP7'><q id='HeUP7'><span id='HeUP7'><b id='HeUP7'><form id='HeUP7'><ins id='HeUP7'></ins><ul id='HeUP7'></ul><sub id='HeUP7'></sub></form><legend id='HeUP7'></legend><bdo id='HeUP7'><pre id='HeUP7'><center id='HeUP7'></center></pre></bdo></b><th id='HeUP7'></th></span></q></dt></tr></i><div id='HeUP7'><tfoot id='HeUP7'></tfoot><dl id='HeUP7'><fieldset id='HeUP7'></fieldset></dl></div>

        • <tfoot id='HeUP7'></tfoot>
              <tbody id='HeUP7'></tbody>

              <legend id='HeUP7'><style id='HeUP7'><dir id='HeUP7'><q id='HeUP7'></q></dir></style></legend>
                  <bdo id='HeUP7'></bdo><ul id='HeUP7'></ul>

                  <small id='HeUP7'></small><noframes id='HeUP7'>

                  本文介绍了Zend Framework 2 和 Doctrine 2 - 多个数据库的配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我将配置文件中的代码粘贴到

                  I pasted the code from the configuration.md file to

                  module.config.php

                  module.config.php

                  'doctrine' => array(
                          'connection' => array(
                              'orm_crawler' => array(
                                  'driverClass' => 'DoctrineDBALDriverPDOMySqlDriver',
                                  'params' => array(
                                      'host'     => 'localhost',
                                      'port'     => '3306',
                                      'user'     => 'root',
                                      'password' => 'root',
                                      'dbname'   => 'crawler',
                                      'driverOptions' => array(
                                          1002 => 'SET NAMES utf8'
                                      ),
                                  )
                              )
                          ),
                  
                          'configuration' => array(
                              'orm_crawler' => array(
                                  'metadata_cache'    => 'array',
                                  'query_cache'       => 'array',
                                  'result_cache'      => 'array',
                                  'driver'            => 'orm_crawler',
                                  'generate_proxies'  => true,
                                  'proxy_dir'         => 'data/DoctrineORMModule/Proxy',
                                  'proxy_namespace'   => 'DoctrineORMModuleProxy',
                                  'filters'           => array()
                              )
                          ),
                  
                          'driver' => array(
                              'Crawler_Driver' => array(
                                  'class' => 'DoctrineORMMappingDriverAnnotationDriver',
                                  'cache' => 'array',
                                  'paths' => array(
                                      __DIR__ . '/../src/Crawler/Entity'
                                  )
                              ),
                              'orm_crawler' => array(
                                  'class'   => 'DoctrineORMMappingDriverDriverChain',
                                  'drivers' => array(
                                      'CrawlerEntity' =>  'Crawler_Driver'
                                  )
                              ),
                          ),
                  
                          'entitymanager' => array(            
                              'orm_crawler' => array(
                                  'connection'    => 'orm_crawler',
                                  'configuration' => 'orm_crawler'
                              )
                          ),
                  
                          'eventmanager' => array(
                              'orm_crawler' => array()
                          ),
                  
                          'sql_logger_collector' => array(
                              'orm_crawler' => array(),
                          ),
                  
                          'entity_resolver' => array(
                              'orm_crawler' => array()
                          ),
                  
                      ),
                  

                  ```

                  模块.php

                  public function getServiceConfig()
                  {
                      return array(
                          'factories' => array(
                  'doctrine.authenticationadapter.orm_crawler'  => new DoctrineModuleServiceAuthenticationAdapterFactory('orm_crawler'),
                                  'doctrine.authenticationstorage.orm_crawler'  => new DoctrineModuleServiceAuthenticationStorageFactory('orm_crawler'),
                                  'doctrine.authenticationservice.orm_crawler'  => new DoctrineModuleServiceAuthenticationAuthenticationServiceFactory('orm_crawler'),
                  
                                  'doctrine.connection.orm_crawler'             => new DoctrineORMModuleServiceDBALConnectionFactory('orm_crawler'),
                                  'doctrine.configuration.orm_crawler'          => new DoctrineORMModuleServiceConfigurationFactory('orm_crawler'),
                                  'doctrine.entitymanager.orm_crawler'          => new DoctrineORMModuleServiceEntityManagerFactory('orm_crawler'),
                  
                                  'doctrine.driver.orm_crawler'                 => new DoctrineModuleServiceDriverFactory('orm_crawler'),
                                  'doctrine.eventmanager.orm_crawler'           => new DoctrineModuleServiceEventManagerFactory('orm_crawler'),
                                  'doctrine.entity_resolver.orm_crawler'        => new DoctrineORMModuleServiceEntityResolverFactory('orm_crawler'),
                                  'doctrine.sql_logger_collector.orm_crawler'   => new DoctrineORMModuleServiceSQLLoggerCollectorFactory('orm_crawler'),
                                  'doctrine.mapping_collector.orm_crawler'      => function (endServiceManagerServiceLocatorInterface $sl) {
                                      $em = $sl->get('doctrine.entitymanager.orm_crawler');
                  
                                      return new DoctrineORMModuleCollectorMappingCollector($em->getMetadataFactory(), 'orm_crawler_mappings');
                                  },
                                  'DoctrineORMModuleFormAnnotationAnnotationBuilder' => function(endServiceManagerServiceLocatorInterface $sl) {
                                      return new DoctrineORMModuleFormAnnotationAnnotationBuilder($sl->get('doctrine.entitymanager.orm_crawler'));
                                  },
                          ),
                      );
                  }
                  

                  我收到以下错误:

                  C:xamppvhostszf2-tradevendorzendframeworkzendframeworklibraryendServiceManagerServiceManager.php:529
                  

                  留言:

                  ZendMvcControllerPluginManager::get was unable to fetch or create an instance for getServiceManager
                  

                  我做错了什么?请帮忙.

                  What am I doing wrong? Please help.

                  问候马修

                  推荐答案

                  Mac,欢迎使用 stackoverflow!您不需要为每个连接分别定义自定义工厂.DoctrineORMModule 已经为我们处理了这项工作.

                  Mac, welcome to stackoverflow! You don't need to define custom factories for each connection respectively. DoctrineORMModule already handles this job for us.

                  当您需要实体管理器时,通过在别名中使用它们的名称从服务定位器实例中获取它,如下所示:

                  When you need the entity managers, get it from service locator instance by using their names in the alias like this:

                  $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
                  

                  $this->getServiceLocator()->get('doctrine.entitymanager.orm_alternative');
                  

                  我正在分享我当前应用程序的数据库配置之一,该配置当前同时使用 PostgreSQL 和 MySQL 连接.

                  I'm sharing one of my current application's database configuration which currently uses both PostgreSQL and MySQL connections.

                  <?php
                  return array(
                      'doctrine' => array(
                          'connection' => array(
                              // Default DB connection
                              'orm_default' => array(
                                  'driverClass' => 'DoctrineDBALDriverPDOPgSqlDriver',
                                  'params' => array(
                                      'host' => '1.2.3.4',
                                      'user' => 'pdbuser',
                                      'port' => '5432',
                                      'password' => '****',
                                      'dbname' => 'mydb',
                                      'driver' => 'pdo_pgsql',
                                  ),
                              ),
                  
                              // Alternative DB connection
                              'orm_alternative' => array(
                                  'driverClass' => 'DoctrineDBALDriverPDOMySqlDriver',
                                  'params' => array(
                                      'host' => '4.5.6.7',
                                      'user' => 'dbuser',
                                      'port' => '3306',
                                      'password' => '****',
                                      'dbname' => 'mydb',
                                      'driver' => 'pdo_mysql',
                                  ),
                              ),
                          ),
                  
                          // Entity Manager instantiation settings
                          'entitymanager' => array(
                              'orm_default' => array(
                                  'connection'    => 'orm_default',
                                  'configuration' => 'orm_default',
                              ),
                              'orm_alternative' => array(
                                  'connection'    => 'orm_alternative',
                                  'configuration' => 'orm_alternative',
                              ),
                          ),
                  
                          // 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_alternative' => array(
                                  'metadata_cache' => 'array',
                                  'query_cache' => 'array',
                                  'result_cache' => 'array',
                                  'hydration_cache' => 'array',
                                  'generate_proxies' => true,
                              ),
                          ),
                      ),
                  );
                  

                  您可以轻松地将此配置与您的配置合并.

                  You can easily merge this configuration with yours.

                  希望有帮助.

                  这篇关于Zend Framework 2 和 Doctrine 2 - 多个数据库的配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                      <tfoot id='hrmMd'></tfoot>

                      <i id='hrmMd'><tr id='hrmMd'><dt id='hrmMd'><q id='hrmMd'><span id='hrmMd'><b id='hrmMd'><form id='hrmMd'><ins id='hrmMd'></ins><ul id='hrmMd'></ul><sub id='hrmMd'></sub></form><legend id='hrmMd'></legend><bdo id='hrmMd'><pre id='hrmMd'><center id='hrmMd'></center></pre></bdo></b><th id='hrmMd'></th></span></q></dt></tr></i><div id='hrmMd'><tfoot id='hrmMd'></tfoot><dl id='hrmMd'><fieldset id='hrmMd'></fieldset></dl></div>
                        <bdo id='hrmMd'></bdo><ul id='hrmMd'></ul>
                          <tbody id='hrmMd'></tbody>
                      • <small id='hrmMd'></small><noframes id='hrmMd'>

                        • <legend id='hrmMd'><style id='hrmMd'><dir id='hrmMd'><q id='hrmMd'></q></dir></style></legend>