1

I'm just experiencing a very weird issue with Symfony2 and Doctrine ORM. It stopped to insert data in one of my tables, no changes were made there in last few months really, but it started to fail, although there's no Doctrine exception or anything, the profiler shows the insert is performed just right. The entity receives ID 0 and there's no record in the database.

It's just a basic persist + flush combination on mapped entity. Yes, the entity is mapped (checked in profiler as well).

I'm wondering if there's any case where Doctrine will not throw an exception despite query not being executed / does not succeed? I have no idea where to look for it. I did check all possible configurations. There's no exception thrown. It all looks perfectly fine, the way it should, but data is not inserted.

I did try to execute the same query directly using command line and it works just fine.

I am using Symfony 2.8, Doctrine version is 2.7.2 for Doctrine\Common, Doctrine\ORM - 2.5.6 (according to composer.lock)

EDIT

I just started getting very weird behaviour from Doctrine all over the place. Few queries return no results when executed from Doctrine ORM, but does work fine when executed directly.

1 Answer 1

2

I did solve this problem. It is related to PDO/DBAL and MySQL prepared statements emulation with use of PDO::ATTR_EMULATE_PREPARES (you can read about it here).

Simply reverting this option to true solved the issue. I had to tweak my other code parts that were relying on false.

Just in case anybody encounter this kind of problem, in Symfony2 this is how I had it configured, simply remove the option 20 to bring back default value. Keep in mind that any DBAL queries returning integers (possibly other types as well) will return strings.

doctrine:
    dbal:
        default_connection: default
        connections:
            default:
                driver:   pdo_mysql
                host:     "%database_host%"
                port:     "%database_port%"
                dbname:   "%database_name%"
                user:     "%database_user%"
                password: "%database_password%"
                charset:  UTF8
                options:
                    20: false // if you have this line and value set to false or 0, just remove it, this option defaults to true
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.