아래와 같이 구성하려고 하는데 잘 안됩니다.
어떻게 하면 좋은지요. 잘 안되는 부분 => where case when 처리
$this->db->where('여기에 where case when ....
when ....
else .. end)
========================================================================================
$this->db->select(' a.idx as idx, a.send_phon as send_phon, a.recv_phon as recv_phon
, a.speck_wait_time as speck_wait_time, 중략-- ');
$this->db->from('intphon_sr a');
$this->db->join('intphon_sr e', 'a.idx = e.idx');
$this->db->join('currency h', '1 = 1');
$this->db->where('여기에 where case when ....
when ....
else .. end)
감사합니다. 덕분에 CI 방식에 맞춰 쿼리를 적용하게되었습니다.
$where = "case
when (SELECT 중략..
else h.idx = 1
end
and a.send_date BETWEEN '{$send_date1}' and '{$send_date2}'
and a.send_phon < 1000000";
$this->db->where($where);
$this->db->select( 'query', false); 2번째가 안에 쿼리문을 감싸지 않고 직접 쿼리문을 실행하는 옵션입니다. 기본은 true 입니다.
$this->db->where('조건 1', null, false); 3번째 옵션이 쿼리문을 감싸지 않고 직접 실행 합니다. 기본은true 입니다.
해당 메뉴얼
http://www.ciboard.co.kr/user_guide/kr/database/query_builder.html