class Main extends KTK_AuthController { ... }
/** * 일반 생성자, 부모 클래스의 생성자를 우선 호출 후, * 해당 클래스의 생성자 역할을 진행하는것이 원칙! * 단, 특정 사유에 의해 부모 클래스의 생성자보다 우선적으로 호출해야 하는 라이브러리가 있는 경우 예외가 될 수 있다. **/ function __construct() { parent::__construct(); // 추가 모듈 작성 $this->load... }
// 모델 선언 $this->load->model('prototype_model'); // 모델의 특정 메소드를 호출하여 data배열에 저장 $data['someThing'] = $this->prototype_model->getSomeThing();
/** * 모델을 선언하는 생성자 * 이런 식으로 선언 시 다른 method에서 중복 선언 할 필요가 없다 **/ function __construct() { parent::__construct(); // 모델 선언 $this->load->model('prototype_model'); } /** * 생성자에서 선언한 모델을 호출하는 method **/ public function something() { // 모델의 특정 메소드를 호출하여 data배열에 저장 $data['someThing'] = $this->prototype_model->getSomeThing(); }
// 뷰 호출 : 일반 페이지일 경우 $this->pageView('/prototype/main_v', $data);
// 뷰 호출 : 공통 header/footer 등 제외 $this->simpleView('/prototype/main_v', $data);
$dataArr = $this->common_model->doSimpleQueryArr(...); // 결과 수신 $this->jsonView($dataArr); // 화면 출력
$isSuccess = "true"; // 텍스트 값 할당 $this->stringView($isSuccess); // 화면 출력
단순히 쿼리만 조회하여 결과값을 화면에 파싱하는 경우 Model 에 관련 method를 만들 경우 필요 없는 코드만 발생할 수 있다.
그래서 이번 프로젝트에서는 commonModel을 통해 별도 business logic이 없는 경우 굳이 model 을 건드리지 않아도 되도록 쿼리 호출 공통함수를 제공한다.
단, 이를 위해서는 쿼리는 queryparser에서 사용할 수 있도록 xml로 제작되어 있어야 한다.