Symfony2 Doctrine PDO Connect MySQL with LOAD DATA LOCAL INFILE

Why do I have this problem?

Warning: PDO::query(): LOAD DATA LOCAL INFILE forbidden in /srv/www/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php on line 742

Here is my configuration.

#app/config/config.yml
doctrine:
    dbal:
        driver:   %database_driver%
        host:     %database_host%
        port:     %database_port%
        dbname:   %database_name%
        user:     %database_user%
        password: %database_password%
        charset:  UTF8
        options:
            "\PDO::MYSQL_ATTR_LOCAL_INFILE": true

    orm:
        auto_generate_proxy_classes: %kernel.debug%
        auto_mapping: true

I tried the options without a guide \.

And if I use this, it works great!

/* @var \Doctrine\DBAL\Connection $connection */
$dbhost = $this->getContainer()->getParameter('database_host');
$dbuser = $this->getContainer()->getParameter('database_user');
$dbpass = $this->getContainer()->getParameter('database_password');
$dbname = $this->getContainer()->getParameter('database_name');

$connection = new \PDO('mysql:host=' . $dbhost . ';dbname=' . $dbname, $dbuser, $dbpass, array(\PDO::MYSQL_ATTR_LOCAL_INFILE => true));

How can I use the doctrine from symfony2 instead of my own new connection \ PDO $.

I don’t know why the doctrine ignores parameters ... Or can Doctrine convert parameters to constant / integer?

+4
source share
1 answer

I tried and decided.

#app/config/config.yml
doctrine:
    dbal:
        driver:   %database_driver%
        host:     %database_host%
        port:     %database_port%
        dbname:   %database_name%
        user:     %database_user%
        password: %database_password%
        charset:  UTF8
        options:
            1001: true

    orm:
        auto_generate_proxy_classes: %kernel.debug%
        auto_mapping: true

Doctrine parameters should not be constants ^^

Use 1001 instead of "\PDO::MYSQL_ATTR_LOCAL_INFILE"fixed issue.

+8
source

Source: https://habr.com/ru/post/1548485/


All Articles