CI 묻고 답하기

제목 엑티브 레코드 관련 질문드려요.
글쓴이 하하예에 작성시각 2016/01/11 19:53:52
댓글 : 2 추천 : 0 스크랩 : 0 조회수 : 13059   RSS
public function insert_cont( $a_prm ){
      $this->db->trans_start();
      $this->db->insert( table1, array( 내용 ));
      $this->db->insert( table2, array( 내용 ));
      
      // 중복부분
      $this->db->insert( table3, array( 내용 ));
      $this->db->insert( table4, array( 내용 ));

      $this->db->trans_complete();

}

 

 

위에 처럼 잘쓰고있습니다.

근데 중복부분이 있어서

 

public function insert_cont( $a_prm ){
      $this->db->trans_start();
      $this->db->insert( table1, array( 내용 ));
      $this->db->insert( table2, array( 내용 ));
      
    // 중복부분 
     $this->db->inserts();

      $this->db->trans_complete();
}

private function inserts(){
      $this->db->insert( table3, array( 내용 ));
      $this->db->insert( table4, array( 내용 ));
}

 

 

이렇게 메소드로 따로 빼서 쓰고싶은데

$this->inserts(); 이렇게도해보고 

$this->db->insert(); 이렇게도 해봤는데 안되더라구요.

방법이 있으면 알려주시면 감사하겠습니다.

 다음글 코드이그나이터 컨트롤러에서 팝업띄우기 질문입니다. (4)
 이전글 없는변수 (3)

댓글

변종원(웅파) / 2016/01/11 21:30:01 / 추천 0

$this->inserts(내용) 내용을 넘겨줘야 처리가 되겠죠.

트랜잭션을 빼고 테스트해보세요.

하하예에 / 2016/01/12 08:37:21 / 추천 0

값을 넘기니 되는군요 감사합니다.^^