phpunit碰到You cannot serialize or unserialize PDO instances
发布时间:2023-09-28 10:49:25 所属栏目:PHP教程 来源:
导读:globalsBackup causes: PDOException: You cannot serialize or unserialize PDO instances。
在PHPUnit/Frameword/TestCase.php文件中,有一行protected $backupGlobals = TRUE;
把backupGlobals 改为false即
在PHPUnit/Frameword/TestCase.php文件中,有一行protected $backupGlobals = TRUE;
把backupGlobals 改为false即
globalsBackup causes: PDOException: You cannot serialize or unserialize PDO instances。 在PHPUnit/Frameword/TestCase.php文件中,有一行protected $backupGlobals = TRUE; 把backupGlobals 改为false即可解决这个问题。不过从PHPUNIT开发小组成员的建议来看,他们是不支持用修改backupGlobals的值来解决这个问题的。 The majority of users of PHPUnit expects it to work as it does when the backup of $GLOBALSfeature is enabled. This is why it is enabled by default. If your tests exercise code that puts unserializable objects into $GLOBALS you can disable the feature. From a software design perspective, you should not have a global instance of PDO to begin with. 所以更好的解决方法就是在: $db = SmartPHP_Db::factory($dbConfig); SmartPHP_Pool::set("db" , $db); SmartPHP_Db_Table::setDefaultAdapter($db); 这段代码之后,再添加一句: unset($db); 这样子就完美解决了You cannot serialize or unserialize PDO instances这个问题。 (编辑:汽车网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐