在symfony 4.3项目中与Oracle 11g数据库的连接

时间:2019-07-16 14:01:51

标签: symfony-4.3

Bonjouràtous, 速效产品4.3和速效产品,从速效产品中提取11克。赛义德·苏菲·索菲尔·苏耶夫·德·苏耶夫·德·苏耶夫的文献速记,通俗易懂的名称和名称以及甲骨文的基础。您需要在此处输入代码,否则您将无法通过此密码输入密码。慈悲的人。

//.env

DATABASE_URL=mysql://user:pass@127.0.0.1:3306/the_spacebar
DATABASE_CUSTOMER_URL=pdo_oci://user:pass@localhost:1521/XE

//doctrine.yaml

doctrine:
    dbal:
        default_connection: default
        connections:
            default:
                # configure these for your database server
                driver: 'pdo_mysql'
                server_version: '5.7'
                charset: utf8mb4
                default_table_options:
                    charset: utf8mb4
                    collate: utf8mb4_unicode_ci

                url: '%env(resolve:DATABASE_URL)%'

            customer:
                # configure these for your database server
                driver: 'pdo_oci'
                server_version: ~
                charset: AL32UTF8
                default_table_options:
                    charset: AL32UTF8
                    collate: ~

                url: '%env(resolve:DATABASE_CUSTOMER_URL)%'

    orm:
        default_entity_manager: default
        entity_managers:
            default:
                connection: default
                mappings:
                    Main:
                        is_bundle: false
                        type: annotation
                        dir: '%kernel.project_dir%/src/Entity/Main'
                        prefix: 'App\Entity\Main'
                        alias: Main
            customer:
                connection: customer
                mappings:
                    Customer:
                        is_bundle: false
                        type: annotation
                        dir: '%kernel.project_dir%/src/Entity/Customer'
                        prefix: 'App\Entity\Customer'
                        alias: Customer

An exception occurred in driver: SQLSTATE[HY000]: pdo_oci_handle_factory: ORA-12505: TNS:listener does not currently know of SID given in connect descriptor  
   (ext\pdo_oci\oci_driver.c:634)

1 个答案:

答案 0 :(得分:0)

我解决了如下问题:

// .env
DATABASE_URL=mysql://user:pass@127.0.0.1:3306/dbname
DATABASE_CUSTOMER_URL=//user:pass@localhost:1521/XE

// doctrine.yaml
doctrine:
    dbal:
        default_connection: default
        connections:
            default:
                # configure these for your database server
                url: '%env(DATABASE_URL)%'
                driver: 'pdo_mysql'
                server_version: '5.7'
                charset: utf8mb4

            customer:
                # configure these for your database server
                url: '%env(DATABASE_CUSTOMER_URL)%'
                driver: 'pdo_oci'
                server_version: ~
                charset: AL32UTF8

    orm:
        default_entity_manager: default
        entity_managers:
            default:
                connection: default
                mappings:
                    Hand:
                        is_bundle: false
                        type: annotation
                        dir: '% kernel.project_dir%/src/Entity/Main'
                        prefix: 'App\Entity\Main'
                        Alias: Main
            customer:
                connection: customer
                mappings:
                    Customer:
                        is_bundle: false
                        type: annotation
                        dir: '%kernel.project_dir%/src/Entity/Customer'
                        prefix: 'App\Entity\Customer'
                        alias: Customer