Symfony2 Doctrine PDO MySQL 连接与 LOAD DATA LOCAL INFILE
为什么我有这个问题?
Warning: PDO::query(): LOAD DATA LOCAL INFILE forbidden in /srv/www/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php on line 742
这是我的配置.
#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 DoctrineDBALConnection $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));
我如何使用来自 symfony2 的学说而不是自己的新 PDO $connection.
我不知道为什么学说会忽略选项......或者说教义不能将选项转换为常量/整数?
I dont know why doctrine ignore the options... Or cant Doctrine convert the options to the Constant/Integer?
推荐答案
尝试并解决.
#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
教义选项不应该是一个常数^^
使用 1001 代替 "PDO::MYSQL_ATTR_LOCAL_INFILE"
解决了问题.
Use 1001 instead "PDO::MYSQL_ATTR_LOCAL_INFILE"
fixed the problem.
相关文章