国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

phpunit遇到You cannot serialize or unserialize PDO instances

2024-05-04 21:50:32
字體:
來源:轉載
供稿:網友

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這個問題。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 永寿县| 固原市| 浦东新区| 巨鹿县| 阿瓦提县| 信宜市| 衡阳市| 连南| 新安县| 南汇区| 左云县| 凤城市| 萝北县| 新乐市| 洛浦县| 泗阳县| 长泰县| 时尚| 永安市| 府谷县| 广丰县| 剑阁县| 沧源| 吉林省| 闽侯县| 滕州市| 遂平县| 隆回县| 南和县| 奎屯市| 周宁县| 南通市| 台湾省| 札达县| 郑州市| 固原市| 湟中县| 游戏| 那曲县| 延安市| 墨玉县|