Created
March 21, 2021 12:07
-
-
Save bohanyang/a46d480d6b17d32a5fa6ee30d82d5dd6 to your computer and use it in GitHub Desktop.
Symfony Oracle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arameters: | |
# Adds a fallback DATABASE_URL if the env var is not set. This allows you | |
# to run cache:warmup even if your environment variables are not available | |
# yet. You should not need to change this value. | |
env(DATABASE_URL): '' | |
services: | |
oracle.listener: | |
class: App\EventSubscriber\OracleSessionInitSubscriber | |
tags: | |
- { name: doctrine.event_listener, event: postConnect } | |
doctrine: | |
dbal: | |
url: '%env(resolve:DATABASE_URL)%' | |
# IMPORTANT: when not use SQLite, you MUST configure your db driver and | |
# server version, either here or in the DATABASE_URL env var (see .env file) | |
# driver: 'pdo_sqlite' | |
# server_version: '3.15' | |
# Only needed for MySQL (ignored otherwise) | |
# charset: utf8mb4 | |
# default_table_options: | |
# collate: utf8mb4_unicode_ci | |
charset: 'AL32UTF8' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\EventSubscriber; | |
use Doctrine\DBAL\Event\ConnectionEventArgs; | |
use Doctrine\DBAL\Event\Listeners\OracleSessionInit; | |
class OracleSessionInitSubscriber extends OracleSessionInit | |
{ | |
public function postConnect(ConnectionEventArgs $args) | |
{ | |
if ($args->getConnection()->getDatabasePlatform()->getName() === 'oracle') { | |
parent::postConnect($args); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment