0
getter/setter를 사용하여 내 Model.Below에 값을 저장하고 검색하려면 컨트롤러 및 모델 코드를 사용하고 싶습니다. 나는 그것을 할 수있는 표준 올바른 방법을 알고 싶습니다?Codeigniter - getters/setters를 사용하여 컨트롤러에서 모델로 값 전달
컨트롤러 코드 :
public function saveevent() {
$this->event_model->setEvent_title($this->input->post('event_title'));
$this->event_model->setSms_description($this->input->post('sms_description'));
$event_id = $this->event_model->saveEvent();
}
모델 코드 :
class Event_Model extends CI_Model{
private $id;
private $event_title;
private $sms_description;
function __construct() {
parent::__construct();
}
public function getId() {
return $this->id;
}
public function setId($id) {
$this->id = $id;
}
public function getEvent_title() {
return $this->event_title;
}
public function setEvent_title($event_title) {
$this->event_title = $event_title;
}
public function getSms_description() {
return $this->sms_description;
}
public function setSms_description($sms_description) {
$this->sms_description = $sms_description;
}
public function saveEvent() {
$data = array(
'title' => $this->getEvent_title() ,
'sms_description' => $this->getSms_description()
);
$this->db->insert('events', $data);
return $this->db->insert_id();
}
}
덕분에이 링크를 참조 맞습니까? – Samy
예, 정확합니다. – Shaolin
@MDeSilva 사람들에게 답을 표시/투표/수락하도록 요청하지 마십시오. 그들은 아무런 압력없이 그곳에서 행동하는 방법을 선택할 수 있습니다. –