去重前

去重前

$result = $this->unique_array_by_key($result,"id");

 function unique_array_by_key($array, $unique_key) {

        $tmp_key[] = array();

        foreach ($array as $key => &$item) {

            if ( is_array($item) && isset($item[$unique_key]) ) {

                if ( in_array($item[$unique_key], $tmp_key) ) {

                    unset($array[$key]);

                } else {

                    $tmp_key[] = $item[$unique_key];

                }

            }

        }

        return $array;

    }

去重后

去重后

查询存在null

$result = M()->query($sql);
        for($i=0;$i<count($result);$i++){
            if(empty($result[$i]["name"])){
                $result[$i]["id"] = -1;
                $result[$i]["name"] = "无区域";
            }
        }

TP3.2.3 设置where 为 null

if($channer_area_id == -1){
                $condition['c.id'] = array('exp','is null');
            }else{}
posted on 2022-12-07 16:40  depressiom  阅读(215)  评论(0)    收藏  举报