4

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
codecowboy
  • 9,835
  • 18
  • 79
  • 134

1 Answers1

6

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.

Paul
  • 139,544
  • 27
  • 275
  • 264
  • 1
    This didn't work for me, wouldn't it pass the option as the literal string instead of the constant value? It looks like loading constants in the YAML is a new feature: http://symfony.com/blog/new-in-symfony-3-2-php-constants-in-yaml-files – Garrett Oct 27 '16 at 21:26