我从不在我的项目中使用 PDO,尤其是序列化和反序列化。但是我得到了这个错误。
Fatal error: Class 'Symfony\Component\HttpKernel\Exception\FlattenException' not found in /var/www/test/mikroskil/mikroweb/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php on line 56 Fatal error: Uncaught exception 'PDOException' with message 'You cannot serialize or unserialize PDO instances' in [no active file]:0 Stack trace: #0 [internal function]: PDO->__sleep() #1 [internal function]: session_write_close() #2 {main} thrown in [no active file] on line 0
这太令人沮丧了。任何人都可以帮助我吗?当我刷新页面时它突然出现。
注意: 我之前有一个错误。 我使用带有 POST 方法的表单。然后我开了一个 session 。 之后,我得到了这个错误。
failed to start the session: already started by php ($_session is set).
我试图修复该错误。但是突然页面显示这个错误
Fatal error: Class 'Symfony\Component\HttpKernel\Exception\FlattenException' not found in /var/www/test/mikroskil/mikroweb/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php on line 56 Fatal error: Uncaught exception 'PDOException' with message 'You cannot serialize or unserialize PDO instances' in [no active file]:0 Stack trace: #0 [internal function]: PDO->__sleep() #1 [internal function]: session_write_close() #2 {main} thrown in [no active file] on line 0
最佳答案
我最近遇到了这个问题,问题是我将我的模型存储在 session 中(内部有事件的 pdo 连接),当请求完成时,php 自动尝试序列化 $_SESSION 以存储在 tmp 文件中。
主要问题是PDO连接无法序列化。如果遇到此问题,您需要检查在哪里序列化任何包含事件 pdo 连接的对象。
关于php - 我从不使用 PDO 序列化或未实现。但是我得到了这个错误 : 'You cannot serialize or unserialize PDO instances' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27794597/