PDOSessionHandler抛出“对非对象调用成员函数prepare()”错误

时间:2015-08-10 08:08:53

标签: php mysql symfony session pdo

我已经实现PdoSessionHandler以便在我的MySQL数据库as described in the docs中保存会话:

# app/config/config.yml
framework:
    session:
        handler_id:      session.handler.pdo
# app/config/services.yml
services:
    session.handler.pdo:
        class:     Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler
        public:    false
        arguments:
            - "mysql:host=%database_host%;dbname=%database_name%"
            - { db_table: _sessions, db_username: %database_user%, db_password: %database_password% }

这 - 一般情况下 - 工作正常(会话在db中保留),但我不断收到此错误:

request.CRITICAL: Uncaught PHP Exception
Symfony\Component\Debug\Exception\FatalErrorException: "Error: Call to a member function
prepare() on a non-object" at /srv/www/code/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php
line 331 {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalErrorException(code: 0):
Error: Call to a member function prepare() on a non-object at /srv/www/code/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php:331)"} []

这是一个错误还是我的实施有问题?

0 个答案:

没有答案