Symfony2 Doctrine PDO MySQL连接与LOAD DATA LOCAL INFILE [英] Symfony2 Doctrine PDO MySQL Connection with LOAD DATA LOCAL INFILE

查看:158
本文介绍了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

我尝试了不带领 \

如果我使用这个,它的效果很好!

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));

我如何使用symfony2的原则,而不是使用自己的新\PDO $连接。 / strong>

How i can use doctrine from symfony2 instead the own new \PDO $connection.

我不知道为什么教义忽略选项...还是不能将Doctrine转换为Constant / Integer选项?

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_LOC AL_INFILE修复了问题。

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

这篇关于Symfony2 Doctrine PDO MySQL连接与LOAD DATA LOCAL INFILE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆