Reputation: 1989
I am using Symfony 2 and want to import a local CSV file with Doctrine:
$connection = $this->entityManager->getConnection();
$output->writeln('Importing Articles');
$path = $this->importHelperService->getCSVBasePath() . 'PromotionArtikel.csv';
$query =
<<<EOF
LOAD DATA LOCAL INFILE '$path' INTO TABLE ProductCSV
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES;
EOF;
$statement = $connection->prepare($query);
$statement->execute();
But I got
[Symfony\Component\Debug\Exception\ContextErrorException]
Warning: PDOStatement::execute(): LOAD DATA LOCAL INFILE forbidden
So I search how can I fix this problem and found this:
Symfony2 Doctrine PDO MySQL Connection with LOAD DATA LOCAL INFILE
But when I try to put the options into my config.yml
doctrine:
dbal:
options:
1001: true
I got an InvalidConfigurationException:
InvalidConfigurationException: Unrecognized option "options" under "doctrine.dbal"
In my composer.lock I search for doctrine/dbal and I can see that version 2.5.12 is installed.
"name": "doctrine/dbal", "version": "v2.5.12",
Anyone an idea how can I solve this problem?
EDIT: Found by myself:
In my config there are different connections. So in this case the "options" have to be configured in the default connection:
doctrine:
dbal:
connections:
default:
options:
1001: true
Upvotes: 2
Views: 1103
Reputation: 6560
The connection options should be defined at dbal.connections.<connection-name>.options
according to the DoctrineBundle 2.5 configuration docs:
doctrine:
dbal:
connections:
default:
options:
# an array of options
key: []
Upvotes: 2