Symfony2 Doctrine PDO MySQL Connection with LOAD DATA LOCAL INFILE
doctrine-orm, mysql, pdo, php, symfony
Solution
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.
Problem
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?