Browse Source

解决报错问题

zhangxiaobin 1 year ago
parent
commit
ca96d92d2f
1 changed files with 4 additions and 2 deletions
  1. 4 2
      thinkphp/library/think/db/Query.php

+ 4 - 2
thinkphp/library/think/db/Query.php

@@ -2563,7 +2563,8 @@ class Query
             // 生成模型对象
             if (count($resultSet) > 0) {
                 foreach ($resultSet as $key => $result) {
-                    if(count(static::$imageUrl) > 0) {
+                    $staticImgUrl = !empty(static::$imageUrl) ? static::$imageUrl : [];//处理php7.2以上版本count报错问题
+                    if(count($staticImgUrl) > 0) {
                         $arrkeys = array_keys($resultSet[0]);
                         foreach(static::$imageUrl as $n) {
                             if(in_array($n,$arrkeys)) {
@@ -2750,7 +2751,8 @@ class Query
         // 数据处理
         if (!empty($result)) {
             if (!empty($this->model)) {
-                if(count(static::$imageUrl) > 0) {
+                $staticImgUrl = !empty(static::$imageUrl) ? static::$imageUrl : [];//处理php7.2以上版本count报错问题
+                if(count($staticImgUrl) > 0) {
                     $arrkeys = array_keys($result);
                     foreach(static::$imageUrl as $n) {
                         if(in_array($n,$arrkeys)) {