首页 > 解决方案 > 如何在 codeigniter 中使用 Find_IN_SET?

问题描述

public function job_fetch($key)
    {
        $this->db->select('*');
        $this->db->from('job');
        $where = "FIND_IN_SET(".$key.", job_title) and FIND_IN_SET(".$key.", city)";
        $this->db->where($where);
        $query = $this->db->get();
        $result = $query->result_array();
        return $result;
    }

在这段代码中,我传递了一个变量,即数组$key在哪里,它看起来像,我想获取数据,如果值在,那么我该如何修复它?请帮我。$keyArray ( [0] => java [1] => developer [2] => hibernate [3] => struts [4] => in [5] => mumbai [6] => noida [7] => delhijob_titlecity$key

谢谢你

标签: phpcodeignitermysqli

解决方案


public function job_fetch($key)
    {
        $this->db->select('*');
        $this->db->from('job');
        $this->db->where("FIND_IN_SET(".$key.", job_title)");
        $this->db->or_where("FIND_IN_SET(".$key.", city)");
        $query = $this->db->get();
        $result = $query->result_array();
        return $result;
    }

推荐阅读