<legend id='4lI1C'><style id='4lI1C'><dir id='4lI1C'><q id='4lI1C'></q></dir></style></legend>

        • <bdo id='4lI1C'></bdo><ul id='4lI1C'></ul>
      1. <small id='4lI1C'></small><noframes id='4lI1C'>

        <i id='4lI1C'><tr id='4lI1C'><dt id='4lI1C'><q id='4lI1C'><span id='4lI1C'><b id='4lI1C'><form id='4lI1C'><ins id='4lI1C'></ins><ul id='4lI1C'></ul><sub id='4lI1C'></sub></form><legend id='4lI1C'></legend><bdo id='4lI1C'><pre id='4lI1C'><center id='4lI1C'></center></pre></bdo></b><th id='4lI1C'></th></span></q></dt></tr></i><div id='4lI1C'><tfoot id='4lI1C'></tfoot><dl id='4lI1C'><fieldset id='4lI1C'></fieldset></dl></div>
      2. <tfoot id='4lI1C'></tfoot>
      3. Doctrine 2 - 如何添加自定义 DBAL 驱动程序?

        时间:2023-08-19
        • <small id='wTu00'></small><noframes id='wTu00'>

            <bdo id='wTu00'></bdo><ul id='wTu00'></ul>

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

            1. <tfoot id='wTu00'></tfoot>
            2. <legend id='wTu00'><style id='wTu00'><dir id='wTu00'><q id='wTu00'></q></dir></style></legend>

                  本文介绍了Doctrine 2 - 如何添加自定义 DBAL 驱动程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如何在不修改 Doctrine2 核心中的 DriverManager.php 的情况下添加我的自定义驱动程序?

                  How can I add my custom driver without modifying DriverManager.php in the Doctrine2 core?

                  我已经为 pdo_dblib 创建了一个 DBAL 驱动程序并将它放在一个 Symfony2 包中.这工作正常,但是我必须将我的驱动程序添加到 DriverManager.php 中的硬编码驱动程序列表中,否则我会收到以下异常:

                  I have created a DBAL Driver for pdo_dblib and placed it inside a Symfony2 bundle. This works fine, however I must add my driver to a list of hard-coded drivers in DriverManager.php, otherwise I get the following exception:

                  例外

                  [DoctrineDBALDBALException]                                                                                                                                                   
                  The given 'driver' pdo_dblib is unknown, Doctrine currently supports only the following drivers: pdo_mysql, pdo_sqlite, pdo_pgsql, pdo_oci, oci8, ibm_db2, pdo_ibm, pdo_sqlsrv
                  

                  除非我修改 DriverManager.php

                  final class DriverManager
                  {
                      private static $_driverMap = array(
                          'pdo_dblib' => 'DoctrineDBALDriverPDODblibDriver', // Added this line
                      );
                  }
                  

                  这是我的 config.yml:

                  # Doctrine Configuration
                  doctrine:
                      dbal:
                          driver:         pdo_dblib
                          driver_class:   PDODblibBundleDoctrineDBALDriverPDODblibDriver
                  

                  推荐答案

                  其实可以的,只需将驱动程序配置选项完全去掉即可.

                  You actually can, just leave the driver configuration option completlely out.

                  您需要定义的只是 driver_class 选项.驱动程序只用于对默认驱动程序类进行内部查找,只要您只提供该类,查找就不会失败.

                  All you need to define is the driver_class option. The driver is only used to do an internal lookup for the default driver classes, as long as you provide the class only, it will not fail doing the lookup.

                  顺便说一句:没有办法(在完整的默认设置中)在 parameters.ini 中定义它,您必须直接在 config.yml 中更改它

                  Btw: There is no way (in a complete default setup) to define this in the parameters.ini, you have to change it directly inside the config.yml

                  顺便说一句:由于另一个缺陷(驱动程序在特定区域回退到mysql),您可能不会在配置中设置字符集,因为它会注册一个用于设置字符集的MySql事件处理程序.

                  Btw: due to another defect (driver falling back to mysql in on specific area), you may not set the charset in the configuration, as it will register an MySql event handler for setting the charset than.

                  因此,基于我的基于 mssql_* 的实现,我的最终学说配置如下所示,并且可以正常工作:

                  So my final doctrine config based on my mssql_* based implementation looks like the following and works without problems:

                  # Doctrine Configuration
                  doctrine:
                      dbal:
                          #driver:   %database_driver%
                          driver_class: DoctrineDBALDriverMsSqlDriver
                          host:     %database_host%
                          port:     %database_port%
                          dbname:   %database_name%
                          user:     %database_user%
                          password: %database_password%
                          #charset:  UTF8
                  
                      orm:
                          auto_generate_proxy_classes: %kernel.debug%
                          auto_mapping: true
                  

                  这篇关于Doctrine 2 - 如何添加自定义 DBAL 驱动程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Doctrine DQL、类表继承和访问子类字段 下一篇:使用过多的 SQL 查询,doctrine2 加载具有 fetch 模式的一对多关联

                  相关文章

                  <legend id='u2qaL'><style id='u2qaL'><dir id='u2qaL'><q id='u2qaL'></q></dir></style></legend>
                1. <i id='u2qaL'><tr id='u2qaL'><dt id='u2qaL'><q id='u2qaL'><span id='u2qaL'><b id='u2qaL'><form id='u2qaL'><ins id='u2qaL'></ins><ul id='u2qaL'></ul><sub id='u2qaL'></sub></form><legend id='u2qaL'></legend><bdo id='u2qaL'><pre id='u2qaL'><center id='u2qaL'></center></pre></bdo></b><th id='u2qaL'></th></span></q></dt></tr></i><div id='u2qaL'><tfoot id='u2qaL'></tfoot><dl id='u2qaL'><fieldset id='u2qaL'></fieldset></dl></div>

                    <bdo id='u2qaL'></bdo><ul id='u2qaL'></ul>
                  1. <small id='u2qaL'></small><noframes id='u2qaL'>

                      <tfoot id='u2qaL'></tfoot>