Archive for June, 2014

h1

Doctrine 2 and Symfony 2 – ORA-01861: literal does not match format string

June 26, 2014

I am using Doctrine 2 and Symfony2 in a PHP application which queries an Oracle database.

Operations which filter on DateTime columns caused the following Exception to be thrown

 [Doctrine\DBAL\DBALException]
An exception occurred while executing 'SELECT ... with params ["1970-01-01 01:00:01", "2014-06-26 15:43:18"]:
ORA-01861: literal does not match format string

This error is Oracle telling you that the datetime parameter is in an unexpected format.

The fix is to put the following code into your app/config/config.yml file

services:
    oracle.listener:
        class: Doctrine\DBAL\Event\Listeners\OracleSessionInit
        tags:
            - { name: doctrine.event_listener, event: postConnect }

This appears to tell Doctrine to use the OracleSessionInit class when connecting.

ref: http://www.doctrine-project.org/jira/browse/DDC-2731