Discuz 修复 对未定义常量(MYSQL_ASSOC)的使用

(PHP 7.2 下)
Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in source\class\discuz\discuz_database.php on line 86 

PHP 7.3(8.0) 可能会对未定义常量的使用直接抛 Error,这里先修复该问题。

upload/source/class/discuz/discuz_database.php

@@ -83,8 +83,10 @@ class discuz_database { @@ -83,8 +83,10 @@ class discuz_database {
 83 return self::$db->insert_id();  83 return self::$db->insert_id();
 84 }  84 }
 85  85
 86 - public static function fetch($resourceid, $type = MYSQL_ASSOC) {  86 + public static function fetch($resourceid, $type = null) {
 87 - if(self::$db->drivertype == 'mysqli') $type = MYSQLI_ASSOC;  87 + if (!isset($type)) {
 88 + $type = self::$db->drivertype == 'mysqli' ? MYSQLI_ASSOC : MYSQL_ASSOC;
 89 + }
 88 return self::$db->fetch_array($resourceid, $type);  90 return self::$db->fetch_array($resourceid, $type);
 89 }  91 }
 90  92
huan

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: