Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2 Doctrine PDO MySQL Connection with LOAD DATA LOCAL INFILE

Why 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

Thats 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 leading \.

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 i can use doctrine from symfony2 instead the own new \PDO $connection.

I dont know why doctrine ignore the options... Or cant Doctrine convert the options to the Constant/Integer?

like image 382
PatrickB Avatar asked Jul 15 '14 12:07

PatrickB


1 Answers

Tried and solved.

#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 options shouldnt be a constant ^^

Use 1001 instead "\PDO::MYSQL_ATTR_LOCAL_INFILE" fixed the problem.

like image 173
PatrickB Avatar answered Oct 05 '22 15:10

PatrickB