mysql 中 find_in_set 函数的使用方法

 

 

复制代码
//4. 根据cate和city 筛选学校 [ 排行榜使用 ]
    public function getSchoolListByCateCity($where,$num,$path) {
        //1. 搜索条件
        if (!empty($where['city_id'])) {
            $data[] = "city_id = ".$where['city_id'];
        }
        if (!empty($where['area_id'])) {
            $data[] = "find_in_set(".$where['area_id'].",area_ids)";
            //find_in_set 函数 ($id,'se_cate_id') 第一个参数id  第二个参数字段名称
        }
        $data[] = 'status=1';
        //2. 排序条件
        $order = ['id' => 'desc'];
        //3. 字段
        $field = 'id,name,url_name,logo,city_id,add_count,class_path,teacher_id,tel,kefu,is_vip';
        $res = $this->where(implode(' AND ',$data))
            ->order($order)
            ->field($field)
            ->paginate([
                'list_rows'=>$num,
                'path' => $path,
            ]);
        //echo $this->getLastSql();
        return $res;
    }
复制代码

 

posted @   棉花糖88  阅读(37)  评论(0编辑  收藏  举报
编辑推荐:
· 理解Rust引用及其生命周期标识(下)
· 从二进制到误差:逐行拆解C语言浮点运算中的4008175468544之谜
· .NET制作智能桌面机器人:结合BotSharp智能体框架开发语音交互
· 软件产品开发中常见的10个问题及处理方法
· .NET 原生驾驭 AI 新基建实战系列:向量数据库的应用与畅想
阅读排行:
· 2025成都.NET开发者Connect圆满结束
· 在 VS Code 中,一键安装 MCP Server!
· 后端思维之高并发处理方案
· langchain0.3教程:从0到1打造一个智能聊天机器人
· 千万级大表的优化技巧
点击右上角即可分享
微信分享提示