Search code examples
phpsymfonypdodoctrine-orm

Can PDO::MYSQL_ATTR_LOCAL_INFILE be set using config files in Symfony2


Is it possible to set the PDO / Doctrine config in Symfony2 to use PDO::MYSQL_ATTR_LOCAL_INFILE => true without using PDO directly?

My use case is loading a csv file into MySQL on Amazon RDS. Symfony version is 2.4

I get the error:

PHP Warning:  PDOStatement::execute(): LOAD DATA LOCAL INFILE forbidden in /.../vendor/doctrine/dbal/lib/Doctrine/DBAL/Statement.php on line 165

Solution

  • Yes, you can set it in your config.yml:

    doctrine:
        dbal:
            options:
                "PDO::MYSQL_ATTR_LOCAL_INFILE": 1
    

    The key must be quoted, because of the colons it contains.