개발 Q&A

제목 ci update 쿼리 질문있습니다.
카테고리 PHP
글쓴이 ci매니아 작성시각 2021/05/25 16:57:21
댓글 : 2 추천 : 0 스크랩 : 0 조회수 : 7473   RSS

$query_field = array(

'prev_count'=>'prev_count+'.$data['prev_count'],

'next_count'=>'next_count+'.$data['next_count']

);

$query_where = array(

'result_date'=>"'".$data['result_date']."'",

'type_no'=>$data['type_no'],

'code'=>$data['code']

);

$query_result = $this->db->update($tablename, $query_field, $query_where);

 

위와 같이 모델쪽 쿼리구문을 작성하였는데요.

작성된 구문을 나타내려는 sql 구문으로는

update $tablename set prev_count=prev_count+$prev_count, next_count=next_count+$next_count where result_date = '$result_date' and type_no = $type_no and code = $code;

이렇게 짜여지지않은건지 쿼리실행이 안되고 있습니다만 위와 같이 사용하면 안되는지요?

위와 다르게 insert구문이나 단순 값변경(증가되는식이 아닌)이나 단일 조건은 위처럼 구문을 작성하여도 잘 동작합니다.

위의 구문을 다중조건과 값증가 하게끔 하려면 어떻게 수정해야하는지 질문드립니다.

 다음글 서비스 규모에 따른 서버 사양 (3)
 이전글 배열 합치기 (3)

댓글

테러보이 / 2021/05/26 09:21:55 / 추천 0
한대승(불의회상) / 2021/05/26 15:22:19 / 추천 0

update SQL을 직접 만드시고 $this->db->query() 로 실행하세요.

$sql = "update ....";
$this->db->query($sql);