Skip to content

Instantly share code, notes, and snippets.

@wpottier
Last active June 22, 2017 13:45
Show Gist options
  • Save wpottier/c87fd7a3a15a739ae18e66fc631f263b to your computer and use it in GitHub Desktop.
Save wpottier/c87fd7a3a15a739ae18e66fc631f263b to your computer and use it in GitHub Desktop.
French DB driver for uncommon localized oracle database
# app/config/config.yml
doctrine:
dbal:
driver_class: GTLocation\Formation\AppBundle\Doctrine\Driver\OracleFrench
host: '%database_host%'
port: '%database_port%'
dbname: '%database_name%'
user: '%database_user%'
password: '%database_password%'
charset: ALT32UTF8
<?php
// src/GTLocation/Formation/AppBundle/Doctrine/Driver/OracleFrench.php
namespace GTLocation\Formation\AppBundle\Doctrine\Driver;
use Doctrine\DBAL\Driver\OCI8\Driver;
class OracleFrench extends Driver
{
/**
* {@inheritdoc}
*/
public function getDatabasePlatform()
{
return new OracleFrenchPlatform();
}
}
<?php
// src/GTLocation/Formation/AppBundle/Doctrine/Driver/OracleFrenchPlatform.php
namespace GTLocation\Formation\AppBundle\Doctrine\Driver;
use Doctrine\DBAL\Platforms\OraclePlatform;
class OracleFrenchPlatform extends OraclePlatform
{
/**
* {@inheritDoc}
*/
public function getDateTimeTzFormatString()
{
return 'd/m/Y H:i:sP';
}
/**
* {@inheritDoc}
*/
public function getDateFormatString()
{
return 'd/m/Y 00:00:00';
}
/**
* {@inheritDoc}
*/
public function getTimeFormatString()
{
return '01/01/1900 H:i:s';
}
}
<?xml version="1.0" ?>
<!-- src/GTLocation/Formation/AppBundle/Resources/config/services.xml -->
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="doctrine.dbal.events.oracle_session_init.listener" class="%doctrine.dbal.events.oracle_session_init.class%">
<argument type="collection">
<argument key="NLS_TIME_FORMAT">HH24:MI:SS</argument>
<argument key="NLS_DATE_FORMAT">DD/MM/YYYY HH24:MI:SS</argument>
<argument key="NLS_TIMESTAMP_FORMAT">DD/MM/YYYY HH24:MI:SS</argument>
<argument key="NLS_TIMESTAMP_TZ_FORMAT">DD/MM/YYYY HH24:MI:SS TZH:TZM</argument>
<argument key="NLS_NUMERIC_CHARACTERS">.,</argument>
</argument>
<tag name="doctrine.event_listener" event="postConnect" />
</service>
</services>
</container>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment