moonsflyer 4 月之前
父節點
當前提交
d41affc35c
共有 1 個文件被更改,包括 13 次插入9 次删除
  1. 13 9
      phalapi/src/app/functions.php

+ 13 - 9
phalapi/src/app/functions.php

@@ -4466,20 +4466,24 @@ namespace App;
             ->where($where)
             ->fetchAll();
         if($rs){
+//
+//            $classid_arr = array_column($rs,'three_classid');
 
-            $classid_arr = array_column($rs,'three_classid');
+            $classid_arr = array_column($rs, 'three_classid');
 
-            $claasid_str = implode(',',$classid_arr);
+            if(!empty($classid_arr)) {
+                // 使用参数化查询更安全
+                $res = \PhalApi\DI()->notorm->shop_goods_class
+                    ->select("gc_id,gc_name,gc_icon")
+                    ->where("gc_id", $classid_arr)  // NotORM支持数组形式的IN查询
+                    ->fetchAll();
+
+                $list = $res;
+            }
 
-            $class_where = " gc_id in '{$claasid_str}'";
-            $res=\PhalApi\DI()->notorm->shop_goods_class
-                ->select("gc_id,gc_name,gc_icon")
-                ->where($class_where)
-                ->fetchAll();
-            $list = $res;
         }
 
-        return $rs;
+        return $list;
     }
 
     // 根据不同条件获取物流列表信息