Archive for June, 2014


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

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

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

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