我想从industry
获得candidate
database
,因为我写了以下内容:
$candidateID = '1,2,3,4,5,6,7,8,9';
function get_industry($candidateID) {
$this->db->select('current_industry');
$this->db->group_by('current_industry');
$this->db->from('candidate_details');
$this->db->where_in('user_id', $candidateID);
$query = $this->db->get();
print_r($this->db->last_query());
if ($query->num_rows() > 0) {
foreach ($query->result() as $row) {
$data[] = $row;
}
return $data;
}
return false;
}
但是当我执行此查询时,它只返回first
9
候选人的行业{/ 1}}
我不知道我在这里失踪了什么..任何帮助或建议都会有很大的帮助..提前谢谢..
答案 0 :(得分:2)
您需要将数据作为数组传递到where_in
中$this->db->where_in('user_id', array(1,2,3,4,5,6,7,8,9));
在你的情况下尝试
$this->db->where_in('user_id', explode(",",$candidateID));
答案 1 :(得分:1)
而不是$this->db->where_in('user_id', $candidateID);
你可以这样做:
$this->db->where_in('user_id', explode(",",$candidateID));
答案 2 :(得分:0)
试试这个
$candidateID = '1,2,3,4,5,6,7,8,9';
function get_industry($candidateID) {
$where = 'user_id in ('.rtrim($candidateID, ",").')';
$this->db->select('current_industry');
$this->db->group_by('current_industry');
$this->db->from('candidate_details');
$this->db->where($where);
$query = $this->db->get();
print_r($this->db->last_query());
if ($query->num_rows() > 0) {
foreach ($query->result() as $row) {
$data[] = $row;
}
return $data;
}
return false;
}